\input{preamble}

% OK, start here.
%
\begin{document}

\title{Modules on Sites}


\maketitle

\phantomsection
\label{section-phantom}

\tableofcontents

\section{Introduction}
\label{section-introduction}

\noindent
In this document we work out basic notions of sheaves of modules on
ringed topoi or ringed sites. We first work out some basic facts on
abelian sheaves. After this we introduce ringed sites and ringed topoi.
We work through some of the very basic notions on (pre)sheaves of
$\mathcal{O}$-modules, analogous to the material on (pre)sheaves of
$\mathcal{O}$-modules in the chapter on sheaves on spaces.
Having done this, we duplicate much of the discussion in the chapter on
sheaves of modules (see Modules, Section \ref{modules-section-introduction}).
Basic references are \cite{FAC}, \cite{EGA} and \cite{SGA4}.






\section{Abelian presheaves}
\label{section-abelian-pre-sheaves}

\noindent
Let $\mathcal{C}$ be a category.
Abelian presheaves were introduced in
Sites, Sections \ref{sites-section-presheaves}
and \ref{sites-section-sheaves} and discussed a bit more
in Sites, Section \ref{sites-section-sheaves-algebraic-structures}.
We will follow the convention of this last reference, in that we think
of an abelian presheaf as a presheaf of sets endowed with addition rules
on all sets of sections compatible with the restriction mappings.
Recall that the category of abelian presheaves on $\mathcal{C}$
is denoted $\textit{PAb}(\mathcal{C})$.

\medskip\noindent
The category $\textit{PAb}(\mathcal{C})$ is abelian as defined in
Homology, Definition \ref{homology-definition-abelian-category}.
Given a map of presheaves $\varphi : \mathcal{G}_1 \to \mathcal{G}_2$
the kernel of $\varphi$ is the abelian presheaf
$U \mapsto \Ker(\mathcal{G}_1(U) \to \mathcal{G}_2(U))$ and
the cokernel of $\varphi$ is the presheaf
$U \mapsto \Coker(\mathcal{G}_1(U) \to \mathcal{G}_2(U))$.
Since the category of abelian groups is abelian it follows that
$\Coim = \Im$ because this holds over each $U$.
A sequence of abelian presheaves
$$
\mathcal{G}_1 \longrightarrow
\mathcal{G}_2 \longrightarrow
\mathcal{G}_3
$$
is exact if and only if
$\mathcal{G}_1(U) \to \mathcal{G}_2(U) \to \mathcal{G}_3(U)$
is an exact sequence of abelian groups for all $U \in \Ob(\mathcal{C})$.
We leave the verifications to the reader.

\begin{lemma}
\label{lemma-limits-colimits-abelian-presheaves}
Let $\mathcal{C}$ be a category.
\begin{enumerate}
\item All limits and colimits exist in $\textit{PAb}(\mathcal{C})$.
\item All limits and colimits commute with taking sections over objects of
$\mathcal{C}$.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $\mathcal{I} \to \textit{PAb}(\mathcal{C})$, $i \mapsto \mathcal{F}_i$
be a diagram. We can simply define abelian presheaves
$L$ and $C$ by the rules
$$
L : U \longmapsto \lim_i \mathcal{F}_i(U)
$$
and
$$
C : U \longmapsto \colim_i \mathcal{F}_i(U).
$$
It is clear that there are maps of abelian presheaves $L \to \mathcal{F}_i$
and $\mathcal{F}_i \to C$, by using the corresponding maps on groups of
sections over each $U$. It is straightforward to check that $L$ and $C$ endowed
with these maps are the limit and colimit of the diagram in
$\textit{PAb}(\mathcal{C})$. This proves (1) and (2). Details omitted.
\end{proof}


\section{Abelian sheaves}
\label{section-abelian-sheaves}

\noindent
Let $\mathcal{C}$ be a site.
The category of abelian sheaves on $\mathcal{C}$ is denoted
$\textit{Ab}(\mathcal{C})$. It is the full subcategory of
$\textit{PAb}(\mathcal{C})$ consisting of those abelian presheaves
whose underlying presheaves of sets are sheaves.
Properties ($\alpha$) -- ($\zeta$) of
Sites, Section \ref{sites-section-sheaves-algebraic-structures}
hold, see
Sites,
Proposition \ref{sites-proposition-functoriality-algebraic-structures-topoi}.
In particular the inclusion functor
$\textit{Ab}(\mathcal{C}) \to \textit{PAb}(\mathcal{C})$
has a left adjoint, namely the sheafification functor
$\mathcal{G} \mapsto \mathcal{G}^\#$.

\medskip\noindent
We suggest the reader prove the lemma on a piece of scratch paper rather
than reading the proof.

\begin{lemma}
\label{lemma-abelian-abelian}
Let $\mathcal{C}$ be a site. Let $\varphi : \mathcal{F} \to \mathcal{G}$
be a morphism of abelian sheaves on $\mathcal{C}$.
\begin{enumerate}
\item The category $\textit{Ab}(\mathcal{C})$ is an abelian category.
\item The kernel $\Ker(\varphi)$ of $\varphi$ is the same as the
kernel of $\varphi$ as a morphism of presheaves.
\item The morphism $\varphi$ is injective
(Homology, Definition \ref{homology-definition-injective-surjective})
if and only if $\varphi$ is injective as a map of presheaves
(Sites, Definition \ref{sites-definition-presheaves-injective-surjective}),
if and only if $\varphi$ is injective as a map of sheaves
(Sites, Definition \ref{sites-definition-sheaves-injective-surjective}).
\item The cokernel $\Coker(\varphi)$ of $\varphi$ is the sheafification
of the cokernel of $\varphi$ as a morphism of presheaves.
\item The morphism $\varphi$ is surjective
(Homology, Definition \ref{homology-definition-injective-surjective})
if and only if $\varphi$ is surjective as a map of sheaves
(Sites, Definition \ref{sites-definition-sheaves-injective-surjective}).
\item A complex of abelian sheaves
$$
\mathcal{F} \to \mathcal{G} \to \mathcal{H}
$$
is exact at $\mathcal{G}$ if and only if for all
$U \in \Ob(\mathcal{C})$ and all $s \in \mathcal{G}(U)$
mapping to zero in $\mathcal{H}(U)$ there exists a covering
$\{U_i \to U\}_{i \in I}$ in $\mathcal{C}$ such that each
$s|_{U_i}$ is in the image of $\mathcal{F}(U_i) \to \mathcal{G}(U_i)$.
\end{enumerate}
\end{lemma}

\begin{proof}
We claim that Homology, Lemma \ref{homology-lemma-adjoint-get-abelian}
applies to the categories $\mathcal{A} = \textit{Ab}(\mathcal{C})$
and $\mathcal{B} = \textit{PAb}(\mathcal{C})$, and the functors
$a : \mathcal{A} \to \mathcal{B}$ (inclusion),  and
$b : \mathcal{B} \to \mathcal{A}$ (sheafification).
Let us check the assumptions of
Homology, Lemma \ref{homology-lemma-adjoint-get-abelian}.
Assumption (1) is that $\mathcal{A}$, $\mathcal{B}$ are additive categories,
$a$, $b$ are additive functors, and $a$ is right adjoint to $b$.
The first two statements are clear and adjointness is
Sites, Section \ref{sites-section-sheaves-algebraic-structures} ($\epsilon$).
Assumption (2) says that $\textit{PAb}(\mathcal{C})$ is abelian
which we saw in Section \ref{section-abelian-pre-sheaves} and
that sheafification is left exact, which is
Sites, Section \ref{sites-section-sheaves-algebraic-structures} ($\zeta$).
The final assumption is that $ba \cong \text{id}_\mathcal{A}$ which is
Sites, Section \ref{sites-section-sheaves-algebraic-structures} ($\delta$).
Hence Homology, Lemma \ref{homology-lemma-adjoint-get-abelian}
applies and we conclude that $\textit{Ab}(\mathcal{C})$ is abelian.

\medskip\noindent
In the proof of Homology, Lemma \ref{homology-lemma-adjoint-get-abelian}
it is shown that $\Ker(\varphi)$ and $\Coker(\varphi)$
are equal to the sheafification of the kernel and cokernel of $\varphi$
as a morphism of abelian presheaves. This proves (4). Since the kernel
is a equalizer (i.e., a limit) and since sheafification commutes with
finite limits, we conclude that (2) holds.

\medskip\noindent
Statement (2) implies (3). Statement (4) implies (5) by our description
of sheafification. The characterization of exactness in (6) follows from
(2) and (5), and the fact that the sequence is exact if and only if
$\Im(\mathcal{F} \to \mathcal{G}) =
\Ker(\mathcal{G} \to \mathcal{H})$.
\end{proof}

\noindent
Another way to say part (6) of the lemma is that a
sequence of abelian sheaves
$$
\mathcal{F}_1 \longrightarrow
\mathcal{F}_2 \longrightarrow
\mathcal{F}_3
$$
is exact if and only if the sheafification of
$U \mapsto \Im(\mathcal{F}_1(U) \to \mathcal{F}_2(U))$
is equal to the kernel of $\mathcal{F}_2 \to \mathcal{F}_3$.

\begin{lemma}
\label{lemma-limits-colimits-abelian-sheaves}
Let $\mathcal{C}$ be a site.
\begin{enumerate}
\item All limits and colimits exist in $\textit{Ab}(\mathcal{C})$.
\item Limits are the same as the corresponding limits of abelian presheaves
over $\mathcal{C}$ (i.e., commute with taking sections over objects of
$\mathcal{C}$).
\item Finite direct sums are the same as the corresponding finite direct sums
in the category of abelian pre-sheaves over $\mathcal{C}$.
\item A colimit is the sheafification of the corresponding colimit in
the category of abelian presheaves.
\item Filtered colimits are exact.
\end{enumerate}
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-limits-colimits-abelian-presheaves} limits and colimits
of abelian presheaves exist, and are described by taking limits and colimits
on the level of sections over objects.

\medskip\noindent
Let $\mathcal{I} \to \textit{Ab}(\mathcal{C})$, $i \mapsto \mathcal{F}_i$
be a diagram. Let $\lim_i \mathcal{F}_i$ be the limit of the diagram
as an abelian presheaf. By Sites, Lemma \ref{sites-lemma-limit-sheaf}
this is an abelian sheaf. Then it is quite easy to see that
$\lim_i \mathcal{F}_i$ is the limit of the diagram in
$\textit{Ab}(\mathcal{C})$. This proves limits exist and (2) holds.

\medskip\noindent
By Categories, Lemma \ref{categories-lemma-adjoint-exact}, and because
sheafification is left adjoint to the inclusion functor we see that
$\colim_i \mathcal{F}$ exists and is the sheafification of the colimit
in $\textit{PAb}(\mathcal{C})$. This proves colimits exist and (4) holds.

\medskip\noindent
Finite direct sums are the same thing as finite products in any abelian
category. Hence (3) follows from (2).

\medskip\noindent
Proof of (5). The statement means that given a system
$0 \to \mathcal{F}_i \to \mathcal{G}_i \to \mathcal{H}_i \to 0$
of exact sequences of abelian sheaves over a directed set $I$ the sequence
$0 \to \colim \mathcal{F}_i \to \colim \mathcal{G}_i \to
\colim \mathcal{H}_i \to 0$ is exact as well. A formal argument using
Homology, Lemma \ref{homology-lemma-check-exactness} and the
definition of colimits shows that the sequence
$\colim \mathcal{F}_i \to \colim \mathcal{G}_i \to \colim \mathcal{H}_i \to 0$
is exact. Note that $\colim \mathcal{F}_i \to \colim \mathcal{G}_i$
is the sheafification of the map of presheaf colimits which is
injective as each of the maps $\mathcal{F}_i \to \mathcal{G}_i$ is
injective. Since sheafification is exact we conclude.
\end{proof}







\section{Free abelian presheaves}
\label{section-free-abelian-presheaf}

\noindent
In order to prepare notation for the following definition, let us agree
to denote the free abelian group on a set $S$ as\footnote{In other chapters
the notation $\mathbf{Z}[S]$ sometimes indicates the polynomial ring over
$\mathbf{Z}$ on $S$.}
$\mathbf{Z}[S] = \bigoplus_{s \in S} \mathbf{Z}$. It is characterized
by the property
$$
\Mor_{\textit{Ab}}(\mathbf{Z}[S], A)
=
\Mor_{\textit{Sets}}(S, A)
$$
In other words the construction $S \mapsto \mathbf{Z}[S]$ is a left adjoint
to the forgetful functor $\textit{Ab} \to \textit{Sets}$.

\begin{definition}
\label{definition-free-abelian-presheaf-on}
Let $\mathcal{C}$ be a category. Let $\mathcal{G}$ be a presheaf of sets.
The {\it free abelian presheaf} $\mathbf{Z}_\mathcal{G}$ on $\mathcal{G}$
is the abelian presheaf defined by the rule
$$
U \longmapsto \mathbf{Z}[\mathcal{G}(U)].
$$
In the special case $\mathcal{G} = h_X$ of a representable presheaf
associated to an object $X$ of $\mathcal{C}$
we use the notation $\mathbf{Z}_X = \mathbf{Z}_{h_X}$. In other words
$$
\mathbf{Z}_X(U) = \mathbf{Z}[\Mor_\mathcal{C}(U, X)].
$$
\end{definition}

\noindent
This construction is clearly functorial in the presheaf $\mathcal{G}$.
In fact it is adjoint to the forgetful functor
$\textit{PAb}(\mathcal{C}) \to \textit{PSh}(\mathcal{C})$.
Here is the precise statement.

\begin{lemma}
\label{lemma-obvious-adjointness}
Let $\mathcal{C}$ be a category.
Let $\mathcal{G}$, $\mathcal{F}$ be a presheaves of sets.
Let $\mathcal{A}$ be an abelian presheaf.
Let $U$ be an object of $\mathcal{C}$. Then
we have
\begin{align*}
\Mor_{\textit{PSh}(\mathcal{C})}(h_U, \mathcal{F})
& =
\mathcal{F}(U), \\
\Mor_{\textit{PAb}(\mathcal{C})}(\mathbf{Z}_\mathcal{G}, \mathcal{A})
& =
\Mor_{\textit{PSh}(\mathcal{C})}(\mathcal{G}, \mathcal{A}), \\
\Mor_{\textit{PAb}(\mathcal{C})}(\mathbf{Z}_U, \mathcal{A})
& =
\mathcal{A}(U).
\end{align*}
All of these equalities are functorial.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-coproduct-sum-free-abelian-presheaf}
Let $\mathcal{C}$ be a category.
Let $I$ be a set. For each $i \in I$ let
$\mathcal{G}_i$ be a presheaf of sets.
Then
$$
\mathbf{Z}_{\coprod_i \mathcal{G}_i}
=
\bigoplus\nolimits_{i \in I} \mathbf{Z}_{\mathcal{G}_i}
$$
in $\textit{PAb}(\mathcal{C})$.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}



\section{Free abelian sheaves}
\label{section-free-abelian-sheaf}

\noindent
Here is the notion of a free abelian sheaf on a sheaf of sets.

\begin{definition}
\label{definition-free-abelian-sheaf-on}
Let $\mathcal{C}$ be a site. Let $\mathcal{G}$ be a presheaf of sets.
The {\it free abelian sheaf} $\mathbf{Z}_\mathcal{G}^\#$
on $\mathcal{G}$ is the abelian sheaf $\mathbf{Z}_\mathcal{G}^\#$
which is the sheafification of the free abelian presheaf on $\mathcal{G}$.
In the special case $\mathcal{G} = h_X$ of a representable presheaf
associated to an object $X$ of $\mathcal{C}$
we use the notation $\mathbf{Z}_X^\#$.
\end{definition}

\noindent
This construction is clearly functorial in the presheaf $\mathcal{G}$.
In fact it provides an adjoint to the forgetful functor
$\textit{Ab}(\mathcal{C}) \to \Sh(\mathcal{C})$.
Here is the precise statement.

\begin{lemma}
\label{lemma-obvious-adjointness-sheaves}
Let $\mathcal{C}$ be a site.
Let $\mathcal{G}$, $\mathcal{F}$ be a sheaves of sets.
Let $\mathcal{A}$ be an abelian sheaf.
Let $U$ be an object of $\mathcal{C}$. Then
we have
\begin{align*}
\Mor_{\Sh(\mathcal{C})}(h_U^\#, \mathcal{F})
& =
\mathcal{F}(U), \\
\Mor_{\textit{Ab}(\mathcal{C})}(\mathbf{Z}_\mathcal{G}^\#,
\mathcal{A})
& =
\Mor_{\Sh(\mathcal{C})}(\mathcal{G}, \mathcal{A}), \\
\Mor_{\textit{Ab}(\mathcal{C})}(\mathbf{Z}_U^\#, \mathcal{A})
& =
\mathcal{A}(U).
\end{align*}
All of these equalities are functorial.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-may-sheafify-before-abelianize}
Let $\mathcal{C}$ be a site.
Let $\mathcal{G}$ be a presheaf of sets.
Then $\mathbf{Z}_\mathcal{G}^\# = (\mathbf{Z}_{\mathcal{G}^\#})^\#$.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}








\section{Ringed sites}
\label{section-ringed-sites}

\noindent
In this chapter we mainly work with sheaves of modules on a ringed site.
Hence we need to define this notion.

\begin{definition}
\label{definition-ringed-site}
Ringed sites.
\begin{enumerate}
\item A {\it ringed site} is a pair $(\mathcal{C}, \mathcal{O})$
where $\mathcal{C}$ is a site and $\mathcal{O}$ is a sheaf of rings
on $\mathcal{C}$. The sheaf $\mathcal{O}$ is called the
{\it structure sheaf} of the ringed site.
\item Let $(\mathcal{C}, \mathcal{O})$, $(\mathcal{C}', \mathcal{O}')$ be ringed
sites. A {\it morphism of ringed sites}
$$
(f, f^\sharp) :
(\mathcal{C}, \mathcal{O})
\longrightarrow
(\mathcal{C}', \mathcal{O}')
$$
is given by a morphism of sites $f : \mathcal{C} \to \mathcal{C}'$
(see Sites, Definition \ref{sites-definition-morphism-sites})
together with a map of sheaves of rings
$f^\sharp : f^{-1}\mathcal{O}' \to \mathcal{O}$, which by adjunction
is the same thing as a map of sheaves of rings
$f^\sharp : \mathcal{O}' \to f_*\mathcal{O}$.
\item Let
$(f, f^\sharp) :
(\mathcal{C}_1, \mathcal{O}_1) \to (\mathcal{C}_2, \mathcal{O}_2)$ and
$(g, g^\sharp) :
(\mathcal{C}_2, \mathcal{O}_2) \to (\mathcal{C}_3, \mathcal{O}_3)$
be morphisms of ringed sites. Then we define
the {\it composition of morphisms of ringed sites}
by the rule
$$
(g, g^\sharp) \circ (f, f^\sharp) = (g \circ f, f^\sharp \circ g^\sharp).
$$
Here we use composition of morphisms of sites defined in
Sites, Definition \ref{sites-definition-composition-morphisms-sites}
and $f^\sharp \circ g^\sharp$ indicates the morphism of sheaves of
rings
$$
\mathcal{O}_3 \xrightarrow{g^\sharp} g_*\mathcal{O}_2
\xrightarrow{g_*f^\sharp} g_*f_*\mathcal{O}_1 = (g \circ f)_*\mathcal{O}_1
$$
\end{enumerate}
\end{definition}






\section{Ringed topoi}
\label{section-ringed-topoi}

\noindent
A ringed topos is just a ringed site, except that the notion of
a morphism of ringed topoi is different from the notion of a morphism
of ringed sites.

\begin{definition}
\label{definition-ringed-topos}
Ringed topoi.
\begin{enumerate}
\item A {\it ringed topos} is a pair
$(\Sh(\mathcal{C}), \mathcal{O})$
where $\mathcal{C}$ is a site and $\mathcal{O}$ is a sheaf of rings
on $\mathcal{C}$. The sheaf $\mathcal{O}$ is called the
{\it structure sheaf} of the ringed topos.
\item Let $(\Sh(\mathcal{C}), \mathcal{O})$,
$(\Sh(\mathcal{C}'), \mathcal{O}')$ be ringed topoi.
A {\it morphism of ringed topoi}
$$
(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O})
\longrightarrow
(\Sh(\mathcal{C}'), \mathcal{O}')
$$
is given by a morphism of topoi $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{C}')$
(see Sites, Definition \ref{sites-definition-topos})
together with a map of sheaves of rings
$f^\sharp : f^{-1}\mathcal{O}' \to \mathcal{O}$, which by adjunction
is the same thing as a map of sheaves of rings
$f^\sharp : \mathcal{O}' \to f_*\mathcal{O}$.
\item Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}_1), \mathcal{O}_1)
\to (\Sh(\mathcal{C}_2), \mathcal{O}_2)$ and
$(g, g^\sharp) :
(\Sh(\mathcal{C}_2), \mathcal{O}_2) \to
(\Sh(\mathcal{C}_3), \mathcal{O}_3)$
be morphisms of ringed topoi. Then we define
the {\it composition of morphisms of ringed topoi}
by the rule
$$
(g, g^\sharp) \circ (f, f^\sharp) = (g \circ f, f^\sharp \circ g^\sharp).
$$
Here we use composition of morphisms of topoi defined in
Sites, Definition \ref{sites-definition-topos}
and $f^\sharp \circ g^\sharp$ indicates the morphism of sheaves of
rings
$$
\mathcal{O}_3 \xrightarrow{g^\sharp} g_*\mathcal{O}_2
\xrightarrow{g_*f^\sharp} g_*f_*\mathcal{O}_1 = (g \circ f)_*\mathcal{O}_1
$$
\end{enumerate}
\end{definition}

\noindent
Every morphism of ringed topoi is the composition of an equivalence
of ringed topoi with a morphism of ringed topoi associated to a morphism
of ringed sites. Here is the precise statement.

\begin{lemma}
\label{lemma-morphism-ringed-topoi-comes-from-morphism-ringed-sites}
Let $(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to (\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi. There exists a factorization
$$
\xymatrix{
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\ar[rr]_{(f, f^\sharp)}
\ar[d]_{(g, g^\sharp)}
& &
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D}) \ar[d]^{(e, e^\sharp)}
\\
(\Sh(\mathcal{C}'), \mathcal{O}_{\mathcal{C}'})
\ar[rr]^{(h, h^\sharp)} & &
(\Sh(\mathcal{D}'), \mathcal{O}_{\mathcal{D}'})
}
$$
where
\begin{enumerate}
\item $g : \Sh(\mathcal{C}) \to \Sh(\mathcal{C}')$
is an equivalence of topoi induced by a special cocontinuous functor
$\mathcal{C} \to \mathcal{C}'$ (see
Sites, Definition \ref{sites-definition-special-cocontinuous-functor}),
\item $e : \Sh(\mathcal{D}) \to \Sh(\mathcal{D}')$
is an equivalence of topoi induced by a special cocontinuous functor
$\mathcal{D} \to \mathcal{D}'$ (see
Sites, Definition \ref{sites-definition-special-cocontinuous-functor}),
\item $\mathcal{O}_{\mathcal{C}'} = g_*\mathcal{O}_\mathcal{C}$
and $g^\sharp$ is the obvious map,
\item $\mathcal{O}_{\mathcal{D}'} = e_*\mathcal{O}_\mathcal{D}$
and $e^\sharp$ is the obvious map,
\item the sites $\mathcal{C}'$ and $\mathcal{D}'$ have final objects
and fibre products (i.e., all finite limits),
\item $h$ is a morphism of sites induced by a continuous functor
$u : \mathcal{D}' \to \mathcal{C}'$ which commutes with all finite limits
(i.e., it satisfies the assumptions of
Sites, Proposition \ref{sites-proposition-get-morphism}), and
\item given any set of sheaves $\mathcal{F}_i$ (resp.\ $\mathcal{G}_j$)
on $\mathcal{C}$ (resp.\ $\mathcal{D}$) we may assume each of these is
a representable sheaf on $\mathcal{C}'$ (resp.\ $\mathcal{D}'$).
\end{enumerate}
Moreover, if $(f, f^\sharp)$ is an equivalence of ringed topoi,
then we can choose the diagram such that
$\mathcal{C}' = \mathcal{D}'$,
$\mathcal{O}_{\mathcal{C}'} = \mathcal{O}_{\mathcal{D}'}$
and $(h, h^\sharp)$ is the identity.
\end{lemma}

\begin{proof}
This follows from
Sites, Lemma \ref{sites-lemma-morphism-topoi-comes-from-morphism-sites},
and
Sites, Remarks
\ref{sites-remark-morphism-topoi-comes-from-morphism-sites} and
\ref{sites-remark-equivalence-topoi-comes-from-morphism-sites}.
You just have to carry along the sheaves of rings. Some details omitted.
\end{proof}







\section{2-morphisms of ringed topoi}
\label{section-2-category}

\noindent
This is a brief section concerning the notion of a $2$-morphism
of ringed topoi.

\begin{definition}
\label{definition-2-morphism-ringed-topoi}
Let
$f, g :
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be two morphisms of ringed topoi. A {\it 2-morphism from $f$ to $g$}
is given by a transformation of functors $t : f_* \to g_*$ such that
$$
\xymatrix{
& \mathcal{O}_\mathcal{D}
\ar[ld]_{f^\sharp}
\ar[rd]^{g^\sharp} \\
f_*\mathcal{O}_\mathcal{C} \ar[rr]^t & &
g_*\mathcal{O}_\mathcal{C}
}
$$
is commutative.
\end{definition}

\noindent
Pictorially we sometimes represent $t$ as follows:
$$
\xymatrix{
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\rrtwocell^f_g{t}
&
&
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})
}
$$
As in
Sites, Section \ref{sites-section-2-category}
giving a 2-morphism $t : f_* \to g_*$ is equivalent to giving
$t : g^{-1} \to f^{-1}$ (usually denoted by the same symbol)
such that the diagram
$$
\xymatrix{
f^{-1}\mathcal{O}_\mathcal{D}
\ar[rd]_{f^\sharp}  & &
g^{-1}\mathcal{O}_\mathcal{D} \ar[ll]^t \ar[ld]^{g^\sharp} \\
& \mathcal{O}_\mathcal{C}
}
$$
is commutative. As in
Sites, Section \ref{sites-section-2-category}
the axioms of a strict 2-category hold with horizontal and
vertical compositions defined as explained in loc.\ cit.










\section{Presheaves of modules}
\label{section-presheaves-modules}

\noindent
Let $\mathcal{C}$ be a category.
Let $\mathcal{O}$ be a presheaf of rings on $\mathcal{C}$.
At this point we have not yet defined a presheaf of $\mathcal{O}$-modules.
Thus we do so right now.

\begin{definition}
\label{definition-presheaf-modules}
Let $\mathcal{C}$ be a category, and
let $\mathcal{O}$ be a presheaf of rings on $\mathcal{C}$.
\begin{enumerate}
\item A {\it presheaf of $\mathcal{O}$-modules}
is given by an abelian presheaf $\mathcal{F}$ together with a
map of presheaves of sets
$$
\mathcal{O} \times \mathcal{F} \longrightarrow \mathcal{F}
$$
such that for every object $U$ of $\mathcal{C}$ the map
$\mathcal{O}(U) \times \mathcal{F}(U) \to \mathcal{F}(U)$
defines the structure of an $\mathcal{O}(U)$-module
structure on the abelian group $\mathcal{F}(U)$.
\item A {\it morphism $\varphi : \mathcal{F} \to \mathcal{G}$
of presheaves of $\mathcal{O}$-modules} is a morphism of abelian presheaves
$\varphi : \mathcal{F} \to \mathcal{G}$ such that
the diagram
$$
\xymatrix{
\mathcal{O} \times \mathcal{F} \ar[r] \ar[d]_{\text{id} \times \varphi} &
\mathcal{F} \ar[d]^{\varphi} \\
\mathcal{O} \times \mathcal{G} \ar[r] &
\mathcal{G}
}
$$
commutes.
\item The set of $\mathcal{O}$-module morphisms as above is
denoted $\Hom_\mathcal{O}(\mathcal{F}, \mathcal{G})$.
\item The category of presheaves of $\mathcal{O}$-modules is denoted
$\textit{PMod}(\mathcal{O})$.
\end{enumerate}
\end{definition}

\noindent
Suppose that $\mathcal{O}_1 \to \mathcal{O}_2$ is a
morphism of presheaves of rings on the category $\mathcal{C}$. In this case,
if $\mathcal{F}$ is a presheaf of $\mathcal{O}_2$-modules
then we can think of $\mathcal{F}$ as a presheaf of
$\mathcal{O}_1$-modules by using the composition
$$
\mathcal{O}_1 \times \mathcal{F}
\to
\mathcal{O}_2 \times \mathcal{F}
\to
\mathcal{F}.
$$
We sometimes denote this by $\mathcal{F}_{\mathcal{O}_1}$
to indicate the restriction of rings. We call this
the {\it restriction of $\mathcal{F}$}. We obtain the
restriction functor
$$
\textit{PMod}(\mathcal{O}_2)
\longrightarrow
\textit{PMod}(\mathcal{O}_1)
$$

\medskip\noindent
On the other hand, given a presheaf of $\mathcal{O}_1$-modules
$\mathcal{G}$
we can construct a presheaf of $\mathcal{O}_2$-modules
$\mathcal{O}_2 \otimes_{p, \mathcal{O}_1} \mathcal{G}$
by the rule
$$
U \longmapsto
\left(\mathcal{O}_2 \otimes_{p, \mathcal{O}_1} \mathcal{G}\right)(U)
=
\mathcal{O}_2(U) \otimes_{\mathcal{O}_1(U)} \mathcal{G}(U)
$$
where $U \in \Ob(\mathcal{C})$, with obvious restriction mappings.
The index $p$ stands for ``presheaf'' and not ``point''.
This presheaf is called the tensor product presheaf. We obtain
the {\it change of rings} functor
$$
\textit{PMod}(\mathcal{O}_1)
\longrightarrow
\textit{PMod}(\mathcal{O}_2)
$$

\begin{lemma}
\label{lemma-adjointness-tensor-restrict-presheaves}
With $\mathcal{C}$, $\mathcal{O}_1 \to \mathcal{O}_2$, $\mathcal{F}$ and
$\mathcal{G}$ as above there exists a canonical bijection
$$
\Hom_{\mathcal{O}_1}(\mathcal{G}, \mathcal{F}_{\mathcal{O}_1})
=
\Hom_{\mathcal{O}_2}(
\mathcal{O}_2 \otimes_{p, \mathcal{O}_1} \mathcal{G},
\mathcal{F}
)
$$
In other words, the restriction and change of rings functors defined
above are adjoint to each other.
\end{lemma}

\begin{proof}
This follows from the fact that for a ring map
$A \to B$ the restriction functor and the change
of ring functor are adjoint to each other.
\end{proof}


\section{Sheaves of modules}
\label{section-sheaves-modules}

\begin{definition}
\label{definition-sheaf-modules}
Let $\mathcal{C}$ be a site.
Let $\mathcal{O}$ be a sheaf of rings on $\mathcal{C}$.
\begin{enumerate}
\item A {\it sheaf of $\mathcal{O}$-modules} is a presheaf
of $\mathcal{O}$-modules $\mathcal{F}$,
see Definition \ref{definition-presheaf-modules},
such that the underlying presheaf of abelian groups $\mathcal{F}$
is a sheaf.
\item A {\it morphism of sheaves of $\mathcal{O}$-modules}
is a morphism of presheaves of $\mathcal{O}$-modules.
\item Given sheaves of $\mathcal{O}$-modules
$\mathcal{F}$ and $\mathcal{G}$ we denote
$\Hom_\mathcal{O}(\mathcal{F}, \mathcal{G})$
the set of morphism of sheaves of $\mathcal{O}$-modules.
\item The category of sheaves of $\mathcal{O}$-modules
is denoted $\textit{Mod}(\mathcal{O})$.
\end{enumerate}
\end{definition}

\noindent
This definition kind of makes sense even if $\mathcal{O}$ is just a
presheaf of rings, although we do not know any examples where
this is useful, and we will avoid using the terminology
``sheaves of $\mathcal{O}$-modules''
in case $\mathcal{O}$ is not a sheaf of rings.



\section{Sheafification of presheaves of modules}
\label{section-sheafification-presheaves-modules}

\begin{lemma}
\label{lemma-sheafification-presheaf-modules}
Let $\mathcal{C}$ be a site.
Let $\mathcal{O}$ be a presheaf of rings on $\mathcal{C}$.
Let $\mathcal{F}$ be a presheaf of $\mathcal{O}$-modules.
Let $\mathcal{O}^\#$ be the sheafification of $\mathcal{O}$ as a presheaf
of rings, see Sites, Section \ref{sites-section-sheaves-algebraic-structures}.
Let $\mathcal{F}^\#$ be the sheafification of $\mathcal{F}$
as a presheaf of abelian groups. There exists a unique map of
sheaves of sets
$$
\mathcal{O}^\# \times \mathcal{F}^\#
\longrightarrow
\mathcal{F}^\#
$$
which makes the diagram
$$
\xymatrix{
\mathcal{O} \times \mathcal{F} \ar[r] \ar[d] &
\mathcal{F} \ar[d] \\
\mathcal{O}^\# \times \mathcal{F}^\# \ar[r] &
\mathcal{F}^\#
}
$$
commute and which makes $\mathcal{F}^\#$ into a sheaf
of $\mathcal{O}^\#$-modules. In addition, if $\mathcal{G}$
is a sheaf of $\mathcal{O}^\#$-modules, then any morphism
of presheaves of $\mathcal{O}$-modules $\mathcal{F} \to \mathcal{G}$
(into the restriction of $\mathcal{G}$ to a $\mathcal{O}$-module)
factors uniquely as $\mathcal{F} \to \mathcal{F}^\# \to \mathcal{G}$
where $\mathcal{F}^\# \to \mathcal{G}$ is a morphism of
$\mathcal{O}^\#$-modules.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\noindent
This actually means that the functor
$i : \textit{Mod}(\mathcal{O}^\#) \to \textit{PMod}(\mathcal{O})$
(combining restriction and including sheaves into presheaves)
and the sheafification functor of the lemma
${}^\# : \textit{PMod}(\mathcal{O}) \to \textit{Mod}(\mathcal{O}^\#)$
are adjoint. In a formula
$$
\Mor_{\textit{PMod}(\mathcal{O})}(\mathcal{F}, i\mathcal{G})
=
\Mor_{\textit{Mod}(\mathcal{O}^\#)}(\mathcal{F}^\#, \mathcal{G})
$$
An important case happens when $\mathcal{O}$ is already a sheaf of
rings. In this case the formula reads
$$
\Mor_{\textit{PMod}(\mathcal{O})}(\mathcal{F}, i\mathcal{G})
=
\Mor_{\textit{Mod}(\mathcal{O})}(\mathcal{F}^\#, \mathcal{G})
$$
because $\mathcal{O} = \mathcal{O}^\#$ in this case.

\begin{lemma}
\label{lemma-sheafification-exact}
Let $\mathcal{C}$ be a site.
Let $\mathcal{O}$ be a presheaf of rings on $\mathcal{C}$
The sheafification functor
$$
\textit{PMod}(\mathcal{O}) \longrightarrow \textit{Mod}(\mathcal{O}^\#), \quad
\mathcal{F} \longmapsto \mathcal{F}^\#
$$
is exact.
\end{lemma}

\begin{proof}
This is true because it holds for sheafification
$\textit{PAb}(\mathcal{C}) \to \textit{Ab}(\mathcal{C})$.
See the discussion in Section \ref{section-abelian-sheaves}.
\end{proof}

\noindent
Let $\mathcal{C}$ be a site.
Let $\mathcal{O}_1 \to \mathcal{O}_2$ be
a morphism of sheaves of rings on $\mathcal{C}$.
In Section \ref{section-presheaves-modules}
we defined a restriction functor
and a change of rings functor on presheaves of modules
associated to this situation.

\medskip\noindent
If $\mathcal{F}$ is a sheaf of $\mathcal{O}_2$-modules
then the restriction $\mathcal{F}_{\mathcal{O}_1}$
of $\mathcal{F}$ is clearly a sheaf
of $\mathcal{O}_1$-modules. We obtain the restriction functor
$$
\textit{Mod}(\mathcal{O}_2)
\longrightarrow
\textit{Mod}(\mathcal{O}_1)
$$

\medskip\noindent
On the other hand, given a sheaf of $\mathcal{O}_1$-modules
$\mathcal{G}$ the presheaf of $\mathcal{O}_2$-modules
$\mathcal{O}_2 \otimes_{p, \mathcal{O}_1} \mathcal{G}$
is in general not a sheaf. Hence we define the
{\it tensor product sheaf}
$\mathcal{O}_2 \otimes_{\mathcal{O}_1} \mathcal{G}$
by the formula
$$
\mathcal{O}_2 \otimes_{\mathcal{O}_1} \mathcal{G}
=
(\mathcal{O}_2 \otimes_{p, \mathcal{O}_1} \mathcal{G})^\#
$$
as the sheafification of our construction for presheaves.
We obtain the {\it change of rings} functor
$$
\textit{Mod}(\mathcal{O}_1)
\longrightarrow
\textit{Mod}(\mathcal{O}_2)
$$

\begin{lemma}
\label{lemma-adjointness-tensor-restrict}
With $X$, $\mathcal{O}_1$, $\mathcal{O}_2$, $\mathcal{F}$ and
$\mathcal{G}$ as above there exists a canonical bijection
$$
\Hom_{\mathcal{O}_1}(\mathcal{G}, \mathcal{F}_{\mathcal{O}_1})
=
\Hom_{\mathcal{O}_2}(
\mathcal{O}_2 \otimes_{\mathcal{O}_1} \mathcal{G},
\mathcal{F}
)
$$
In other words, the restriction and change of rings functors
are adjoint to each other.
\end{lemma}

\begin{proof}
This follows from
Lemma \ref{lemma-adjointness-tensor-restrict-presheaves}
and the fact that
$\Hom_{\mathcal{O}_2}(
\mathcal{O}_2 \otimes_{\mathcal{O}_1} \mathcal{G},
\mathcal{F}
)
=
\Hom_{\mathcal{O}_2}(
\mathcal{O}_2 \otimes_{p, \mathcal{O}_1} \mathcal{G},
\mathcal{F}
)$
because $\mathcal{F}$ is a sheaf.
\end{proof}

\begin{lemma}
\label{lemma-epimorphism-modules}
Let $\mathcal{C}$ be a site.
Let $\mathcal{O} \to \mathcal{O}'$ be an epimorphism of sheaves of rings.
Let $\mathcal{G}_1, \mathcal{G}_2$ be $\mathcal{O}'$-modules.
Then
$$
\Hom_{\mathcal{O}'}(\mathcal{G}_1, \mathcal{G}_2) =
\Hom_\mathcal{O}(\mathcal{G}_1, \mathcal{G}_2).
$$
In other words, the restriction functor
$\textit{Mod}(\mathcal{O}') \to \textit{Mod}(\mathcal{O})$ is fully faithful.
\end{lemma}

\begin{proof}
This is the sheaf version of
Algebra, Lemma \ref{algebra-lemma-epimorphism-modules}
and is proved in exactly the same way.
\end{proof}




\section{Morphisms of topoi and sheaves of modules}
\label{section-sheaves-modules-functorial}

\noindent
All of this material is completely straightforward.
We formulate everything in the case of morphisms of topoi,
but of course the results also hold in the case of morphisms of sites.

\begin{lemma}
\label{lemma-pushforward-module}
Let $\mathcal{C}$, $\mathcal{D}$ be sites.
Let $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$
be a morphism of topoi.
Let $\mathcal{O}$ be a sheaf of rings on $\mathcal{C}$.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}$-modules.
There is a natural map of sheaves of sets
$$
f_*\mathcal{O} \times f_*\mathcal{F}
\longrightarrow
f_*\mathcal{F}
$$
which turns $f_*\mathcal{F}$ into a sheaf of $f_*\mathcal{O}$-modules.
This construction is functorial in $\mathcal{F}$.
\end{lemma}

\begin{proof}
Denote $\mu : \mathcal{O} \times \mathcal{F} \to \mathcal{F}$ the
multiplication map. Recall that $f_*$ (on sheaves of sets) is left exact
and hence commutes with products. Hence $f_*\mu$ is a map as
indicated. This proves the lemma.
\end{proof}

\begin{lemma}
\label{lemma-pullback-module}
Let $\mathcal{C}$, $\mathcal{D}$ be sites.
Let $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$
be a morphism of topoi.
Let $\mathcal{O}$ be a sheaf of rings on $\mathcal{D}$.
Let $\mathcal{G}$ be a sheaf of $\mathcal{O}$-modules.
There is a natural map of sheaves of sets
$$
f^{-1}\mathcal{O} \times f^{-1}\mathcal{G}
\longrightarrow
f^{-1}\mathcal{G}
$$
which turns $f^{-1}\mathcal{G}$ into a sheaf of $f^{-1}\mathcal{O}$-modules.
This construction is functorial in $\mathcal{G}$.
\end{lemma}

\begin{proof}
Denote $\mu : \mathcal{O} \times \mathcal{G} \to \mathcal{G}$ the
multiplication map. Recall that $f^{-1}$ (on sheaves of sets) is exact
and hence commutes with products. Hence $f^{-1}\mu$ is a map as
indicated. This proves the lemma.
\end{proof}

\begin{lemma}
\label{lemma-adjoint-push-pull-modules}
Let $\mathcal{C}$, $\mathcal{D}$ be sites.
Let $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$
be a morphism of topoi.
Let $\mathcal{O}$ be a sheaf of rings on $\mathcal{D}$.
Let $\mathcal{G}$ be a sheaf of $\mathcal{O}$-modules.
Let $\mathcal{F}$ be a sheaf of $f^{-1}\mathcal{O}$-modules.
Then
$$
\Mor_{\textit{Mod}(f^{-1}\mathcal{O})}(f^{-1}\mathcal{G}, \mathcal{F})
=
\Mor_{\textit{Mod}(\mathcal{O})}(\mathcal{G}, f_*\mathcal{F}).
$$
Here we use
Lemmas \ref{lemma-pullback-module}
and \ref{lemma-pushforward-module}, and we think of
$f_*\mathcal{F}$ as an $\mathcal{O}$-module by restriction via
$\mathcal{O} \to f_*f^{-1}\mathcal{O}$.
\end{lemma}

\begin{proof}
First we note that we have
$$
\Mor_{\textit{Ab}(\mathcal{C})}(f^{-1}\mathcal{G}, \mathcal{F})
=
\Mor_{\textit{Ab}(\mathcal{D})}(\mathcal{G}, f_*\mathcal{F}).
$$
by Sites,
Proposition \ref{sites-proposition-functoriality-algebraic-structures-topoi}.
Suppose that $\alpha : f^{-1}\mathcal{G} \to \mathcal{F}$ and
$\beta : \mathcal{G} \to f_*\mathcal{F}$ are morphisms of abelian
sheaves which correspond via the formula above. We have to show that
$\alpha$ is $f^{-1}\mathcal{O}$-linear if and only if $\beta$
is $\mathcal{O}$-linear. For example, suppose $\alpha$ is
$f^{-1}\mathcal{O}$-linear, then clearly $f_*\alpha$ is
$f_*f^{-1}\mathcal{O}$-linear, and hence (as restriction is a functor)
is $\mathcal{O}$-linear. Hence it suffices to prove that the
adjunction map $\mathcal{G} \to f_*f^{-1}\mathcal{G}$ is
$\mathcal{O}$-linear. Using that both $f_*$ and $f^{-1}$ commute
with products (on sheaves of sets) this comes down to showing that
$$
\xymatrix{
\mathcal{O} \times \mathcal{G} \ar[r] \ar[d] &
f_*f^{-1}(\mathcal{O} \times \mathcal{G}) \ar[d] \\
\mathcal{G} \ar[r] & f_*f^{-1}\mathcal{G}
}
$$
is commutative. This holds because the adjunction mapping
$\text{id}_{\Sh(\mathcal{D})} \to f_*f^{-1}$ is a
transformation of functors. We omit the proof of the implication
$\beta$ linear $\Rightarrow$ $\alpha$ linear.
\end{proof}

\begin{lemma}
\label{lemma-adjoint-pull-push-modules}
Let $\mathcal{C}$, $\mathcal{D}$ be sites.
Let $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$
be a morphism of topoi.
Let $\mathcal{O}$ be a sheaf of rings on $\mathcal{C}$.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}$-modules.
Let $\mathcal{G}$ be a sheaf of $f_*\mathcal{O}$-modules.
Then
$$
\Mor_{\textit{Mod}(\mathcal{O})}(
\mathcal{O} \otimes_{f^{-1}f_*\mathcal{O}} f^{-1}\mathcal{G}, \mathcal{F})
=
\Mor_{\textit{Mod}(f_*\mathcal{O})}(\mathcal{G}, f_*\mathcal{F}).
$$
Here we use
Lemmas \ref{lemma-pullback-module}
and \ref{lemma-pushforward-module}, and we use
the canonical map $f^{-1}f_*\mathcal{O} \to \mathcal{O}$
in the definition of the tensor product.
\end{lemma}

\begin{proof}
Note that we have
$$
\Mor_{\textit{Mod}(\mathcal{O})}(
\mathcal{O} \otimes_{f^{-1}f_*\mathcal{O}} f^{-1}\mathcal{G}, \mathcal{F})
=
\Mor_{\textit{Mod}(f^{-1}f_*\mathcal{O})}(
f^{-1}\mathcal{G}, \mathcal{F}_{f^{-1}f_*\mathcal{O}})
$$
by Lemma \ref{lemma-adjointness-tensor-restrict}. Hence the result follows
from Lemma \ref{lemma-adjoint-push-pull-modules}.
\end{proof}






\section{Morphisms of ringed topoi and modules}
\label{section-functoriality-modules}

\noindent
We have now introduced enough notation so that we are able to
define the pullback and pushforward of modules along a morphism
of ringed topoi.

\begin{definition}
\label{definition-pushforward}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi or ringed sites.
\begin{enumerate}
\item Let $\mathcal{F}$ be a sheaf of $\mathcal{O}_\mathcal{C}$-modules.
We define the {\it pushforward} of $\mathcal{F}$ as the
sheaf of $\mathcal{O}_\mathcal{D}$-modules which as a sheaf
of abelian groups equals $f_*\mathcal{F}$ and with
module structure given by the restriction
via $f^\sharp : \mathcal{O}_\mathcal{D} \to f_*\mathcal{O}_\mathcal{C}$
of the module structure
$$
f_*\mathcal{O}_\mathcal{C} \times f_*\mathcal{F}
\longrightarrow
f_*\mathcal{F}
$$
from Lemma \ref{lemma-pushforward-module}.
\item Let $\mathcal{G}$ be a sheaf of $\mathcal{O}_\mathcal{D}$-modules.
We define the {\it pullback} $f^*\mathcal{G}$ to be the
sheaf of $\mathcal{O}_\mathcal{C}$-modules defined by the formula
$$
f^*\mathcal{G}
=
\mathcal{O}_\mathcal{C} \otimes_{f^{-1}\mathcal{O}_\mathcal{D}}
f^{-1}\mathcal{G}
$$
where the ring map
$f^{-1}\mathcal{O}_\mathcal{D} \to \mathcal{O}_\mathcal{C}$
is $f^\sharp$, and where the  module
structure is given by Lemma \ref{lemma-pullback-module}.
\end{enumerate}
\end{definition}

\noindent
Thus we have defined functors
\begin{eqnarray*}
f_* : \textit{Mod}(\mathcal{O}_\mathcal{C})
& \longrightarrow &
\textit{Mod}(\mathcal{O}_\mathcal{D}) \\
f^* : \textit{Mod}(\mathcal{O}_\mathcal{D})
& \longrightarrow &
\textit{Mod}(\mathcal{O}_\mathcal{C})
\end{eqnarray*}
The final result on these functors is that they are indeed
adjoint as expected.

\begin{lemma}
\label{lemma-adjoint-pullback-pushforward-modules}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi or ringed sites.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}_\mathcal{C}$-modules.
Let $\mathcal{G}$ be a sheaf of $\mathcal{O}_\mathcal{D}$-modules.
There is a canonical bijection
$$
\Hom_{\mathcal{O}_\mathcal{C}}(f^*\mathcal{G}, \mathcal{F})
=
\Hom_{\mathcal{O}_\mathcal{D}}(\mathcal{G}, f_*\mathcal{F}).
$$
In other words: the functor $f^*$ is the left adjoint to
$f_*$.
\end{lemma}

\begin{proof}
This follows from the work we did before:
\begin{eqnarray*}
\Hom_{\mathcal{O}_\mathcal{C}}(f^*\mathcal{G}, \mathcal{F})
& = &
\Mor_{\textit{Mod}(\mathcal{O}_\mathcal{C})}(
\mathcal{O}_\mathcal{C}
\otimes_{f^{-1}\mathcal{O}_\mathcal{D}} f^{-1}\mathcal{G},
\mathcal{F}) \\
& = &
\Mor_{\textit{Mod}(f^{-1}\mathcal{O}_\mathcal{D})}(
f^{-1}\mathcal{G}, \mathcal{F}_{f^{-1}\mathcal{O}_\mathcal{D}}) \\
& = &
\Hom_{\mathcal{O}_\mathcal{D}}(\mathcal{G}, f_*\mathcal{F}).
\end{eqnarray*}
Here we use Lemmas \ref{lemma-adjointness-tensor-restrict}
and \ref{lemma-adjoint-push-pull-modules}.
\end{proof}

\begin{lemma}
\label{lemma-push-pull-composition-modules}
$(f, f^\sharp) :
(\Sh(\mathcal{C}_1), \mathcal{O}_1)
\to (\Sh(\mathcal{C}_2), \mathcal{O}_2)$ and
$(g, g^\sharp) :
(\Sh(\mathcal{C}_2), \mathcal{O}_2) \to
(\Sh(\mathcal{C}_3), \mathcal{O}_3)$
be morphisms of ringed topoi.
There are canonical isomorphisms of functors
$(g \circ f)_* \cong g_* \circ f_*$ and
$(g \circ f)^* \cong f^* \circ g^*$.
\end{lemma}

\begin{proof}
This is clear from the definitions.
\end{proof}





\section{The abelian category of sheaves of modules}
\label{section-kernels}

\noindent
Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a ringed topos.
Let $\mathcal{F}$, $\mathcal{G}$ be sheaves of $\mathcal{O}$-modules, see
Sheaves, Definition \ref{sheaves-definition-sheaf-modules}.
Let $\varphi, \psi : \mathcal{F} \to \mathcal{G}$
be morphisms of sheaves of $\mathcal{O}$-modules.
We define $\varphi + \psi : \mathcal{F} \to \mathcal{G}$
to be the sum of $\varphi$ and $\psi$ as morphisms of abelian sheaves.
This is clearly again a map of $\mathcal{O}$-modules.
It is also clear that composition of maps of
$\mathcal{O}$-modules is bilinear with respect to this
addition. Thus $\textit{Mod}(\mathcal{O})$ is a pre-additive
category, see Homology, Definition \ref{homology-definition-preadditive}.

\medskip\noindent
We will denote $0$ the sheaf of $\mathcal{O}$-modules
which has constant value $\{0\}$ for all objects $U$ of $\mathcal{C}$.
Clearly this is both a final and an initial object of
$\textit{Mod}(\mathcal{O})$. Given a morphism
of $\mathcal{O}$-modules $\varphi : \mathcal{F} \to \mathcal{G}$
the following are equivalent:
(a) $\varphi$ is zero, (b) $\varphi$ factors through $0$,
(c) $\varphi$ is zero on sections over each object $U$.

\medskip\noindent
Moreover, given a pair
$\mathcal{F}$, $\mathcal{G}$ of sheaves of $\mathcal{O}$-modules
we may define the direct sum as
$$
\mathcal{F} \oplus \mathcal{G} = \mathcal{F} \times \mathcal{G}
$$
with obvious maps $(i, j, p, q)$ as in Homology, Definition
\ref{homology-definition-direct-sum}. Thus $\textit{Mod}(\mathcal{O})$
is an additive category, see
Homology, Definition \ref{homology-definition-additive-category}.

\medskip\noindent
Let $\varphi : \mathcal{F} \to \mathcal{G}$ be a morphism
of $\mathcal{O}$-modules. We may define $\Ker(\varphi)$
to be the kernel of $\varphi$ as a map of abelian sheaves.
By Section \ref{section-abelian-sheaves} this is the
subsheaf of $\mathcal{F}$ with sections
$$
\Ker(\varphi)(U) =
\{ s \in \mathcal{F}(U) \mid \varphi(s) = 0 \text{ in } \mathcal{G}(U)\}
$$
for all objects $U$ of $\mathcal{C}$. It is easy to see that this is indeed
a kernel in the category of $\mathcal{O}$-modules. In other words,
a morphism $\alpha : \mathcal{H} \to \mathcal{F}$ factors
through $\Ker(\varphi)$ if and only if $\varphi \circ \alpha = 0$.

\medskip\noindent
Similarly, we define $\Coker(\varphi)$ as the cokernel of
$\varphi$ as a map of abelian sheaves. There is a unique
multiplication map
$$
\mathcal{O} \times \Coker(\varphi) \longrightarrow \Coker(\varphi)
$$
such that the map $\mathcal{G} \to \Coker(\varphi)$ becomes a
morphism of $\mathcal{O}$-modules (verification omitted).
The map $\mathcal{G} \to \Coker(\varphi)$ is surjective
(as a map of sheaves of sets, see Section \ref{section-abelian-sheaves}).
To show that $\Coker(\varphi)$ is a cokernel in
$\textit{Mod}(\mathcal{O})$, note that if
$\beta : \mathcal{G} \to \mathcal{H}$ is a morphism of $\mathcal{O}$-modules
such that $\beta \circ \varphi$ is zero, then you get for every
object $U$ of $\mathcal{C}$ a map induced by $\beta$ from
$\mathcal{G}(U)/\varphi(\mathcal{F}(U))$ into $\mathcal{H}(U)$.
By the universal property of sheafification (see
Sheaves, Lemma \ref{sheaves-lemma-sheafification-presheaf-modules})
we obtain a canonical map $\Coker(\varphi) \to \mathcal{H}$
such that the original $\beta$ is equal to the composition
$\mathcal{G} \to \Coker(\varphi) \to \mathcal{H}$.
The morphism $\Coker(\varphi) \to \mathcal{H}$ is unique
because of the surjectivity mentioned above.

\begin{lemma}
\label{lemma-abelian}
Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a ringed topos.
The category $\textit{Mod}(\mathcal{O})$ is an abelian category.
The forgetful functor
$\textit{Mod}(\mathcal{O}) \to \textit{Ab}(\mathcal{C})$
is exact, hence kernels, cokernels and exactness of
$\mathcal{O}$-modules, correspond to the corresponding notions
for abelian sheaves.
\end{lemma}

\begin{proof}
Above we have seen that $\textit{Mod}(\mathcal{O})$ is an additive
category, with kernels and cokernels
and that $\textit{Mod}(\mathcal{O}) \to \textit{Ab}(\mathcal{C})$
preserves kernels and cokernels.
By Homology, Definition \ref{homology-definition-abelian-category}
we have to show that image and coimage agree. This is clear
because it is true in $\textit{Ab}(\mathcal{C})$. The lemma follows.
\end{proof}

\begin{lemma}
\label{lemma-limits-colimits}
Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a ringed topos.
All limits and colimits exist in $\textit{Mod}(\mathcal{O})$
and the forgetful functor
$\textit{Mod}(\mathcal{O}) \to \textit{Ab}(\mathcal{C})$
commutes with them. Moreover, filtered colimits are exact.
\end{lemma}

\begin{proof}
The final statement follows from the first as filtered colimits are
exact in $\textit{Ab}(\mathcal{C})$ by
Lemma \ref{lemma-limits-colimits-abelian-sheaves}.
Let $\mathcal{I} \to \textit{Mod}(\mathcal{C})$, $i \mapsto \mathcal{F}_i$
be a diagram. Let $\lim_i \mathcal{F}_i$ be the limit of the diagram
in $\textit{Ab}(\mathcal{C})$. By the description of this limit in
Lemma \ref{lemma-limits-colimits-abelian-sheaves} we see immediately that
there exists a multiplication
$$
\mathcal{O} \times \lim_i \mathcal{F}_i
\longrightarrow
\lim_i \mathcal{F}_i
$$
which turns $\lim_i \mathcal{F}_i$ into a sheaf of
$\mathcal{O}$-modules. It is easy to see that this is the
limit of the diagram in $\textit{Mod}(\mathcal{C})$. Let
$\colim_i \mathcal{F}_i$ be the colimit of the diagram
in $\textit{PAb}(\mathcal{C})$. By the description of this colimit
in the proof of Lemma \ref{lemma-limits-colimits-abelian-presheaves}
we see immediately that there exists a multiplication
$$
\mathcal{O} \times \colim_i \mathcal{F}_i
\longrightarrow
\colim_i \mathcal{F}_i
$$
which turns $\colim_i \mathcal{F}_i$ into a presheaf of
$\mathcal{O}$-modules. Applying sheafification we get a
sheaf of $\mathcal{O}$-modules $(\colim_i \mathcal{F}_i)^\#$,
see Lemma \ref{lemma-sheafification-presheaf-modules}.
It is easy to see that $(\colim_i \mathcal{F}_i)^\#$
is the colimit of the diagram in $\textit{Mod}(\mathcal{O})$, and
by Lemma \ref{lemma-limits-colimits-abelian-sheaves}
forgetting the $\mathcal{O}$-module structure is
the colimit in $\textit{Ab}(\mathcal{C})$.
\end{proof}

\noindent
The existence of limits and colimits allows us to consider exactness
properties of functors defined on the category of $\mathcal{O}$-modules
in terms of limits and colimits, as in
Categories, Section \ref{categories-section-exact-functor}.
See Homology, Lemma \ref{homology-lemma-exact-functor} for a description of
exactness properties in terms of short exact sequences.

\begin{lemma}
\label{lemma-exactness-pushforward-pullback}
Let $f : (\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to (\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi.
\begin{enumerate}
\item The functor $f_*$ is left exact. In fact it commutes with
all limits.
\item The functor $f^*$ is right exact. In fact it commutes
with all colimits.
\end{enumerate}
\end{lemma}

\begin{proof}
This is true because $(f^*, f_*)$ is an adjoint pair
of functors, see
Lemma \ref{lemma-adjoint-pullback-pushforward-modules}.
See Categories, Section \ref{categories-section-adjoint}.
\end{proof}

\begin{lemma}
\label{lemma-check-exactness-stalks}
Let $\mathcal{C}$ be a site. If $\{p_i\}_{i \in I}$ is a conservative
family of points, then we may check exactness of a sequence of abelian
sheaves on the stalks at the points $p_i$, $i \in I$.
If $\mathcal{C}$ has enough points, then
exactness of a sequence of abelian sheaves may
be checked on stalks.
\end{lemma}

\begin{proof}
This is immediate from
Sites, Lemma \ref{sites-lemma-exactness-stalks}.
\end{proof}





\section{Exactness of pushforward}
\label{section-pushforward}

\noindent
Some technical lemmas concerning exactness properties of pushforward.

\begin{lemma}
\label{lemma-reflect-surjections}
Let $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$ be
a morphism of topoi. The following are equivalent:
\begin{enumerate}
\item $f^{-1}f_*\mathcal{F} \to \mathcal{F}$ is surjective for
all $\mathcal{F}$ in $\textit{Ab}(\mathcal{C})$, and
\item $f_* : \textit{Ab}(\mathcal{C}) \to \textit{Ab}(\mathcal{D})$
reflects surjections.
\end{enumerate}
In this case the functor
$f_* : \textit{Ab}(\mathcal{C}) \to \textit{Ab}(\mathcal{D})$
is faithful.
\end{lemma}

\begin{proof}
Assume (1). Suppose that $a : \mathcal{F} \to \mathcal{F}'$
is a map of abelian sheaves on $\mathcal{C}$ such that $f_*a$ is surjective.
As $f^{-1}$ is exact this implies that
$f^{-1}f_*a : f^{-1}f_*\mathcal{F} \to f^{-1}f_*\mathcal{F}'$
is surjective. Combined with (1) this implies that $a$ is surjective.
This means that (2) holds.

\medskip\noindent
Assume (2). Let $\mathcal{F}$ be an abelian sheaf on $\mathcal{C}$.
We have to show that the map $f^{-1}f_*\mathcal{F} \to \mathcal{F}$ is
surjective. By (2) it suffices to show that
$f_*f^{-1}f_*\mathcal{F} \to f_*\mathcal{F}$ is surjective.
And this is true because there is a canonical map
$f_*\mathcal{F} \to f_*f^{-1}f_*\mathcal{F}$ which is a one-sided inverse.

\medskip\noindent
We omit the proof of the final assertion.
\end{proof}

\begin{lemma}
\label{lemma-exactness}
Let $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$ be
a morphism of topoi. Assume at least one of the following properties
holds
\begin{enumerate}
\item $f_*$ transforms surjections of sheaves of sets into surjections,
\item $f_*$ transforms surjections of abelian sheaves into surjections,
\item $f_*$ commutes with coequalizers on sheaves of sets,
\item $f_*$ commutes with pushouts on sheaves of sets,
\end{enumerate}
Then $f_* : \textit{Ab}(\mathcal{C}) \to \textit{Ab}(\mathcal{D})$
is exact.
\end{lemma}

\begin{proof}
Since $f_* : \textit{Ab}(\mathcal{C}) \to \textit{Ab}(\mathcal{D})$
is a right adjoint we already know that it transforms a short exact sequence
$0 \to \mathcal{F}_1 \to \mathcal{F}_2 \to \mathcal{F}_3 \to 0$
of abelian sheaves on $\mathcal{C}$ into an exact sequence
$$
0 \to f_*\mathcal{F}_1 \to f_*\mathcal{F}_2 \to f_*\mathcal{F}_3
$$
see
Categories, Sections \ref{categories-section-exact-functor} and
\ref{categories-section-adjoint}
and
Homology, Section \ref{homology-section-functors}. Hence it suffices to
prove that the map $f_*\mathcal{F}_2 \to f_*\mathcal{F}_3$ is surjective.
If (1), (2) holds, then this is clear from the definitions. By
Sites, Lemma \ref{sites-lemma-exactness-properties}
we see that either (3) or (4) formally implies (1), hence in these cases
we are done also.
\end{proof}

\begin{lemma}
\label{lemma-morphism-ringed-sites-almost-cocontinuous}
Let $f : \mathcal{D} \to \mathcal{C}$ be a morphism of sites
associated to the continuous functor $u : \mathcal{C} \to \mathcal{D}$.
Assume $u$ is almost cocontinuous. Then
\begin{enumerate}
\item $f_* : \textit{Ab}(\mathcal{D}) \to \textit{Ab}(\mathcal{C})$ is exact.
\item if $f^\sharp : f^{-1}\mathcal{O}_\mathcal{C} \to \mathcal{O}_\mathcal{D}$
is given so that $f$ becomes a morphism of ringed sites, then
$f_* : \textit{Mod}(\mathcal{O}_\mathcal{D}) \to
\textit{Mod}(\mathcal{O}_\mathcal{C})$ is exact.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (2) follows from part (1) by
Lemma \ref{lemma-limits-colimits}.
Part (1) follows from
Sites, Lemmas
\ref{sites-lemma-morphism-of-sites-almost-cocontinuous} and
\ref{sites-lemma-exactness-properties}.
\end{proof}





\section{Exactness of lower shriek}
\label{section-exactness-lower-shriek}

\noindent
Let $u : \mathcal{C} \to \mathcal{D}$ be a functor between sites.
Assume that
\begin{enumerate}
\item[(a)] $u$ is cocontinuous, and
\item[(b)] $u$ is continuous.
\end{enumerate}
Let $g : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$ be the
morphism of topoi associated with $u$, see
Sites, Lemma \ref{sites-lemma-cocontinuous-morphism-topoi}.
Recall that $g^{-1} = u^p$, i.e., $g^{-1}$ is given by the simple formula
$(g^{-1}\mathcal{G})(U) = \mathcal{G}(u(U))$, see
Sites, Lemma \ref{sites-lemma-when-shriek}.
We would like to show that
$g^{-1} : \textit{Ab}(\mathcal{D}) \to \textit{Ab}(\mathcal{C})$
has a left adjoint $g_!$. By
Sites, Lemma \ref{sites-lemma-when-shriek}
the functor $g^{Sh}_! = (u_p\ )^\#$ is a left adjoint on sheaves of sets.
Moreover, we know that $g^{Sh}_!\mathcal{F}$ is the sheaf
associated to the presheaf
$$
V \longmapsto \colim_{V \to u(U)} \mathcal{F}(U)
$$
where the colimit is over $(\mathcal{I}_V^u)^{opp}$ and is taken in the
category of sets. Hence the following definition is natural.

\begin{definition}
\label{definition-g-shriek}
With $u : \mathcal{C} \to \mathcal{D}$ satisfying (a), (b) above.
For $\mathcal{F} \in \textit{PAb}(\mathcal{C})$ we define
{\it $g_{p!}\mathcal{F}$} as the presheaf
$$
V \longmapsto \colim_{V \to u(U)} \mathcal{F}(U)
$$
with colimits over $(\mathcal{I}_V^u)^{opp}$ taken in $\textit{Ab}$. For
$\mathcal{F} \in \textit{PAb}(\mathcal{C})$ we set
{\it $g_!\mathcal{F} = (g_{p!}\mathcal{F})^\#$}.
\end{definition}

\noindent
The reason for being so explicit with this is that the functors
$g^{Sh}_!$ and $g_!$ are different. Whenever we use both
we have to be careful to make the distinction clear.

\begin{lemma}
\label{lemma-g-shriek-adjoint}
The functor $g_{p!}$ is a left adjoint to the functor $u^p$.
The functor $g_!$ is a left adjoint to the functor $g^{-1}$.
In other words the formulas
\begin{align*}
\Mor_{\textit{PAb}(\mathcal{C})}(\mathcal{F}, u^p\mathcal{G})
& =
\Mor_{\textit{PAb}(\mathcal{D})}(g_{p!}\mathcal{F}, \mathcal{G}), \\
\Mor_{\textit{Ab}(\mathcal{C})}(\mathcal{F}, g^{-1}\mathcal{G})
& =
\Mor_{\textit{Ab}(\mathcal{D})}(g_!\mathcal{F}, \mathcal{G})
\end{align*}
hold bifunctorially in $\mathcal{F}$ and $\mathcal{G}$.
\end{lemma}

\begin{proof}
The second formula follows formally from the first, since if
$\mathcal{F}$ and $\mathcal{G}$ are abelian sheaves then
\begin{align*}
\Mor_{\textit{Ab}(\mathcal{C})}(\mathcal{F}, g^{-1}\mathcal{G})
& =
\Mor_{\textit{PAb}(\mathcal{D})}(g_{p!}\mathcal{F}, \mathcal{G}) \\
& =
\Mor_{\textit{Ab}(\mathcal{D})}(g_!\mathcal{F}, \mathcal{G})
\end{align*}
by the universal property of sheafification.

\medskip\noindent
To prove the first formula, let $\mathcal{F}$, $\mathcal{G}$ be abelian
presheaves. To prove the lemma we will construct maps from the group on the
left to the group on the right and omit the verification that these are
mutually inverse.

\medskip\noindent
Note that there is a canonical map of abelian presheaves
$\mathcal{F} \to u^pg_{p!}\mathcal{F}$ which on sections over $U$ is the
natural map
$\mathcal{F}(U) \to \colim_{u(U) \to u(U')} \mathcal{F}(U')$, see
Sites, Lemma \ref{sites-lemma-recover}.
Given a map $\alpha : g_{p!}\mathcal{F} \to \mathcal{G}$
we get $u^p\alpha : u^pg_{p!}\mathcal{F} \to u^p\mathcal{G}$.
which we can precompose by the map $\mathcal{F} \to u^pg_{p!}\mathcal{F}$.

\medskip\noindent
Note that there is a canonical map of abelian presheaves
$g_{p!}u^p\mathcal{G} \to \mathcal{G}$ which on sections over
$V$ is the natural map
$\colim_{V \to u(U)} \mathcal{G}(u(U)) \to \mathcal{G}(V)$.
It maps a section $s \in u(U)$ in the summand corresponding to
$t : V \to u(U)$ to $t^*s \in \mathcal{G}(V)$.
Hence, given a map $\beta : \mathcal{F} \to u^p\mathcal{G}$
we get a map $g_{p!}\beta : g_{p!}\mathcal{F} \to g_{p!}u^p\mathcal{G}$
which we can postcompose with the map $g_{p!}u^p\mathcal{G} \to \mathcal{G}$
above.
\end{proof}

\begin{lemma}
\label{lemma-exactness-lower-shriek}
Let $\mathcal{C}$ and $\mathcal{D}$ be sites.
Let $u : \mathcal{C} \to \mathcal{D}$ be a functor.
Assume that
\begin{enumerate}
\item[(a)] $u$ is cocontinuous,
\item[(b)] $u$ is continuous, and
\item[(c)] fibre products and equalizers exist in $\mathcal{C}$ and
$u$ commutes with them.
\end{enumerate}
In this case the functor
$g_! : \textit{Ab}(\mathcal{C}) \to \textit{Ab}(\mathcal{D})$
is exact.
\end{lemma}

\begin{proof}
Compare with
Sites, Lemma \ref{sites-lemma-preserve-equalizers}.
Assume (a), (b), and (c).
We already know that $g_!$ is right exact as it is a left adjoint, see
Categories, Lemma \ref{categories-lemma-exact-adjoint} and
Homology, Section \ref{homology-section-functors}.
We have $g_! = (g_{p!}\ )^\#$. We have to show that
$g_!$ transforms injective maps of abelian sheaves into injective maps
of abelian presheaves.
Recall that sheafification of abelian presheaves is exact, see
Lemma \ref{lemma-limits-colimits-abelian-sheaves}.
Thus it suffices to show that $g_{p!}$ transforms injective maps of
abelian presheaves into injective maps of abelian presheaves.
To do this it suffices that colimits over the categories
$(\mathcal{I}_V^u)^{opp}$ of
Sites, Section \ref{sites-section-functoriality-PSh}
transform injective maps between diagrams into injections.
This follows from
Sites, Lemma \ref{sites-lemma-almost-directed}
and
Algebra, Lemma \ref{algebra-lemma-almost-directed-colimit-exact}.
\end{proof}

\begin{lemma}
\label{lemma-back-and-forth}
Let $\mathcal{C}$ and $\mathcal{D}$ be sites.
Let $u : \mathcal{C} \to \mathcal{D}$ be a functor.
Assume that
\begin{enumerate}
\item[(a)] $u$ is cocontinuous,
\item[(b)] $u$ is continuous, and
\item[(c)] $u$ is fully faithful.
\end{enumerate}
For $g_!, g^{-1}, g_*$ as above the canonical maps
$\mathcal{F} \to g^{-1}g_!\mathcal{F}$ and
$g^{-1}g_*\mathcal{F} \to \mathcal{F}$
are isomorphisms
for all abelian sheaves $\mathcal{F}$ on $\mathcal{C}$.
\end{lemma}

\begin{proof}
The map $g^{-1}g_*\mathcal{F} \to \mathcal{F}$ is an isomorphism
by Sites, Lemma \ref{sites-lemma-back-and-forth} and the fact that
pullback and pushforward of abelian sheaves agrees with
pullback and pushforward on the underlying sheaves of sets.

\medskip\noindent
Pick $U \in \Ob(\mathcal{C})$. We will show that
$g^{-1}g_!\mathcal{F}(U) = \mathcal{F}(U)$. First, note that
$g^{-1}g_!\mathcal{F}(U) = g_!\mathcal{F}(u(U))$. Hence it suffices
to show that $g_!\mathcal{F}(u(U)) = \mathcal{F}(U)$.
We know that $g_!\mathcal{F}$ is the (abelian) sheaf associated
to the presheaf $g_{p!}\mathcal{F}$ which is defined by the rule
$$
V \longmapsto \colim_{V \to u(U')} \mathcal{F}(U')
$$
with colimit taken in $\textit{Ab}$. If $V = u(U)$, then, as $u$ is
fully faithful this colimit is over $U \to U'$. Hence we conclude
that $g_{p!}\mathcal{F}(u(U) = \mathcal{F}(U)$.
Since $u$ is cocontinuous and continuous any covering of $u(U)$ in
$\mathcal{D}$ can be refined by a covering (!) $\{u(U_i) \to u(U)\}$
of $\mathcal{D}$ where $\{U_i \to U\}$ is a covering in $\mathcal{C}$.
This implies that $(g_{p!}\mathcal{F})^+(u(U)) = \mathcal{F}(U)$ also,
since in the colimit defining the value of $(g_{p!}\mathcal{F})^+$
on $u(U)$ we may restrict to the cofinal system of coverings
$\{u(U_i) \to u(U)\}$ as above. Hence we see that
$(g_{p!}\mathcal{F})^+(u(U)) = \mathcal{F}(U)$ for all objects $U$
of $\mathcal{C}$ as well. Repeating this argument one more time
gives the equality $(g_{p!}\mathcal{F})^\#(u(U)) = \mathcal{F}(U)$
for all objects $U$ of $\mathcal{C}$. This produces the desired
equality $g^{-1}g_!\mathcal{F} = \mathcal{F}$.
\end{proof}

\begin{remark}
\label{remark-no-extension}
In general the functor $g_!$ cannot be extended to categories of modules
in case $g$ is (part of) a morphism of ringed topoi. Namely, given any
ring map $A \to B$ the functor $M \mapsto B \otimes_A M$ has a right adjoint
(restriction) but not in general a left adjoint (because its existence
would imply that $A \to B$ is flat). We will see in
Section \ref{section-localize}
below that it is possible to define $j_!$ on sheaves of modules
in the case of a localization of sites.
We will discuss this in greater generality in
Section \ref{section-lower-shriek-modules} below.
\end{remark}

\begin{lemma}
\label{lemma-have-left-adjoint}
Let $\mathcal{C}$ and $\mathcal{D}$ be sites. Let
$g : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$ be the morphism of topoi
associated to a continuous and cocontinuous functor
$u : \mathcal{C} \to \mathcal{D}$.
\begin{enumerate}
\item If $u$ has a left adjoint $w$, then $g_!$ agrees with $g_!^{\Sh}$
on underlying sheaves of sets and $g_!$ is exact.
\item If in addition $w$ is cocontinuous, then $g_! = h^{-1}$ and
$g^{-1} = h_*$ where
$h : \Sh(\mathcal{D}) \to \Sh(\mathcal{C})$ is the morphism of topoi
associated to $w$.
\end{enumerate}
\end{lemma}

\begin{proof}
This Lemma is the analogue of
Sites, Lemma \ref{sites-lemma-have-left-adjoint}.
From Sites, Lemma \ref{sites-lemma-adjoint-functors} we see that the categories
$\mathcal{I}_V^u$ have an initial object. Thus the underlying set of a
colimit of a system of abelian groups over $(\mathcal{I}_V^u)^{opp}$
is the colimit of the underlying sets. Whence the agreement
of $g_!^{\Sh}$ and $g_!$ by our construction of $g_!$ in
Definition \ref{definition-g-shriek}.
The exactness and (2) follow immediately from the corresponding statements of
Sites, Lemma \ref{sites-lemma-have-left-adjoint}.
\end{proof}





\section{Global types of modules}
\label{section-global}

\begin{definition}
\label{definition-global}
Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a ringed topos.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}$-modules.
\begin{enumerate}
\item We say $\mathcal{F}$ is a {\it free $\mathcal{O}$-module}
if $\mathcal{F}$ is isomorphic as an $\mathcal{O}$-module
to a sheaf of the form $\bigoplus_{i \in I} \mathcal{O}$.
\item We say $\mathcal{F}$ is {\it finite free} if
$\mathcal{F}$ is isomorphic as an $\mathcal{O}$-module
to a sheaf of the form $\bigoplus_{i \in I} \mathcal{O}$
with a finite index set $I$.
\item We say $\mathcal{F}$ is {\it generated by global sections}
if there exists a surjection
$$
\bigoplus\nolimits_{i \in I} \mathcal{O} \longrightarrow \mathcal{F}
$$
from a free $\mathcal{O}$-module onto $\mathcal{F}$.
\item Given $r \geq 0$ we say $\mathcal{F}$ is
{\it generated by $r$ global sections} if there exists a surjection
$\mathcal{O}^{\oplus r} \to \mathcal{F}$.
\item We say $\mathcal{F}$ is {\it generated by finitely many global sections}
if it is generated by $r$ global sections for some $r \geq 0$.
\item We say $\mathcal{F}$ has a {\it global presentation}
if there exists an exact sequence
$$
\bigoplus\nolimits_{j \in J} \mathcal{O} \longrightarrow
\bigoplus\nolimits_{i \in I} \mathcal{O} \longrightarrow
\mathcal{F} \longrightarrow 0
$$
of $\mathcal{O}$-modules.
\item We say $\mathcal{F}$ has a {\it global finite presentation}
if there exists an exact sequence
$$
\bigoplus\nolimits_{j \in J} \mathcal{O} \longrightarrow
\bigoplus\nolimits_{i \in I} \mathcal{O} \longrightarrow
\mathcal{F} \longrightarrow 0
$$
of $\mathcal{O}$-modules with $I$ and $J$ finite sets.
\end{enumerate}
\end{definition}

\noindent
Note that for any set $I$ the direct sum
$\bigoplus_{i \in I} \mathcal{O}$ exists
(Lemma \ref{lemma-limits-colimits})
and is the sheafification of the presheaf
$U \mapsto \bigoplus_{i \in I} \mathcal{O}(U)$.
This module is called the {\it free $\mathcal{O}$-module on the set $I$}.

\begin{lemma}
\label{lemma-global-pullback}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi.
Let $\mathcal{F}$ be an $\mathcal{O}_\mathcal{D}$-module.
\begin{enumerate}
\item If $\mathcal{F}$ is free then $f^*\mathcal{F}$ is free.
\item If $\mathcal{F}$ is finite free then $f^*\mathcal{F}$ is finite free.
\item If $\mathcal{F}$ is generated by global sections
then $f^*\mathcal{F}$ is generated by global sections.
\item Given $r \geq 0$ if $\mathcal{F}$ is generated by $r$ global
sections, then $f^*\mathcal{F}$ is generated by $r$ global sections.
\item If $\mathcal{F}$ is generated by finitely many global sections
then $f^*\mathcal{F}$ is generated by finitely many global sections.
\item If $\mathcal{F}$ has a global presentation then
$f^*\mathcal{F}$ has a global presentation.
\item If $\mathcal{F}$ has a finite global presentation
then $f^*\mathcal{F}$ has a finite global presentation.
\end{enumerate}
\end{lemma}

\begin{proof}
This is true because $f^*$ commutes with arbitrary colimits
(Lemma \ref{lemma-exactness-pushforward-pullback})
and $f^*\mathcal{O}_\mathcal{D} = \mathcal{O}_\mathcal{C}$.
\end{proof}






\section{Intrinsic properties of modules}
\label{section-intrinsic}

\noindent
Let $\mathcal{P}$ be a property of sheaves of modules on ringed topoi.
We say $\mathcal{P}$ is an {\it intrinsic property} if we have
$\mathcal{P}(\mathcal{F}) \Leftrightarrow \mathcal{P}(f^*\mathcal{F})$
whenever $(f, f^\sharp) :
(\Sh(\mathcal{C}'), \mathcal{O}')
\to
(\Sh(\mathcal{C}), \mathcal{O})$
is an equivalence of ringed topoi.
For example, the property of being free is intrinsic. Indeed, the free
$\mathcal{O}$-module on the set $I$ is characterized by the property
that
$$
\Mor_{\textit{Mod}(\mathcal{O})}(
\bigoplus\nolimits_{i \in I} \mathcal{O},
\mathcal{F})
=
\prod\nolimits_{i \in I} \Mor_{\Sh(\mathcal{C})}(\{*\},
\mathcal{F})
$$
for a variable $\mathcal{F}$ in $\textit{Mod}(\mathcal{O})$.
Alternatively, we can also use Lemma \ref{lemma-global-pullback}
to see that being free is intrinsic. In fact, each of the properties
defined in Definition \ref{definition-global} is intrinsic for the
same reason.
How will we go about defining other intrinsic properties of
$\mathcal{O}$-modules?

\medskip\noindent
The upshot of
Lemma \ref{lemma-morphism-ringed-topoi-comes-from-morphism-ringed-sites}
is the following: Suppose you want to define
an intrinsic property $\mathcal{P}$ of an $\mathcal{O}$-module on a
topos. Then you can proceed as follows:
\begin{enumerate}
\item Given any site $\mathcal{C}$, any sheaf of rings $\mathcal{O}$
on $\mathcal{C}$ and any $\mathcal{O}$-module $\mathcal{F}$
define the corresponding
property $\mathcal{P}(\mathcal{C}, \mathcal{O}, \mathcal{F})$.
\item For any pair of sites $\mathcal{C}$, $\mathcal{C}'$, any
special cocontinuous functor $u : \mathcal{C} \to \mathcal{C}'$,
any sheaf of rings $\mathcal{O}$ on $\mathcal{C}$ any
$\mathcal{O}$-module $\mathcal{F}$, show that
$$
\mathcal{P}(\mathcal{C}, \mathcal{O}, \mathcal{F})
\Leftrightarrow
\mathcal{P}(\mathcal{C}', g_*\mathcal{O}, g_*\mathcal{F})
$$
where $g : \Sh(\mathcal{C}) \to \Sh(\mathcal{C}')$
is the equivalence of topoi associated to $u$.
\end{enumerate}
In this case, given any ringed topos $(\Sh(\mathcal{C}), \mathcal{O})$
and any sheaf of $\mathcal{O}$-modules $\mathcal{F}$ we simply say that
$\mathcal{F}$ has property $\mathcal{P}$ if
$\mathcal{P}(\mathcal{C}, \mathcal{O}, \mathcal{F})$ is true.
And Lemma \ref{lemma-morphism-ringed-topoi-comes-from-morphism-ringed-sites}
combined with (2) above guarantees that this is well defined.

\medskip\noindent
Moreover, the same
Lemma \ref{lemma-morphism-ringed-topoi-comes-from-morphism-ringed-sites}
also guarantees that if in addition
\begin{enumerate}
\item[(3)] For any morphism of ringed sites
$(f, f^\sharp) :
(\mathcal{C}, \mathcal{O}_\mathcal{C})
\to
(\mathcal{D}, \mathcal{O}_\mathcal{D})$
such that $f$ is given by a functor
$u : \mathcal{D} \to \mathcal{C}$ satisfying the
assumptions of Sites, Proposition \ref{sites-proposition-get-morphism},
and any $\mathcal{O}_\mathcal{D}$-module $\mathcal{G}$
we have
$$
\mathcal{P}(\mathcal{D}, \mathcal{O}_\mathcal{D}, \mathcal{F})
\Rightarrow
\mathcal{P}(\mathcal{C}, \mathcal{O}_\mathcal{C}, f^*\mathcal{F})
$$
\end{enumerate}
then it is true that $\mathcal{P}$ is preserved under pullback
of modules w.r.t.\ arbitrary morphisms of ringed topoi.

\medskip\noindent
We will use this method in the following sections to see
that:
locally free,
locally generated by sections,
locally generated by $r$ sections,
finite type,
finite presentation,
quasi-coherent, and
coherent
are intrinsic properties of modules.

\medskip\noindent
Perhaps a more satisfying method would be to find an intrinsic definition
of these notions, rather than the laborious process sketched here.
On the other hand, in many geometric situations where we want to apply
these definitions we are given a definite ringed site, and a definite
sheaf of modules, and it is nice to have a definition already adapted to
this language.




\section{Localization of ringed sites}
\label{section-localize}

\noindent
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $U \in \Ob(\mathcal{C})$.
We explain the counterparts of the results in
Sites, Section \ref{sites-section-localize}
in this setting.

\medskip\noindent
Denote
$\mathcal{O}_U = j_U^{-1}\mathcal{O}$ the restriction of $\mathcal{O}$
to the site $\mathcal{C}/U$. It is described by the simple
rule $\mathcal{O}_U(V/U) = \mathcal{O}(V)$. With this notation
the localization morphism $j_U$ becomes a morphism of ringed topoi
$$
(j_U, j_U^\sharp) :
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\longrightarrow
(\Sh(\mathcal{C}), \mathcal{O})
$$
namely, we take $j_U^\sharp : j_U^{-1}\mathcal{O} \to \mathcal{O}_U$
the identity map.
Moreover, we obtain the following descriptions for pushforward
and pullback of modules.

\begin{definition}
\label{definition-localize-ringed-site}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $U \in \Ob(\mathcal{C})$.
\begin{enumerate}
\item The ringed site $(\mathcal{C}/U, \mathcal{O}_U)$ is called the
{\it localization of the ringed site $(\mathcal{C}, \mathcal{O})$
at the object $U$}.
\item The morphism of ringed topoi
$(j_U, j_U^\sharp) :
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\to
(\Sh(\mathcal{C}), \mathcal{O})$
is called the {\it localization morphism}.
\item The functor
$j_{U*} : \textit{Mod}(\mathcal{O}_U) \to \textit{Mod}(\mathcal{O})$
is called the {\it direct image functor}.
\item For a sheaf of $\mathcal{O}$-modules $\mathcal{F}$ on $\mathcal{C}$
the sheaf $j_U^*\mathcal{F}$ is called the
{\it restriction of $\mathcal{F}$ to $\mathcal{C}/U$}.
We will sometimes denote it by
$\mathcal{F}|_{\mathcal{C}/U}$ or even $\mathcal{F}|_U$.
It is described by the simple rule $j_U^*(\mathcal{F})(X/U) = \mathcal{F}(X)$.
\item The left adjoint
$j_{U!} : \textit{Mod}(\mathcal{O}_U) \to \textit{Mod}(\mathcal{O})$
of restriction is called {\it extension by zero}. It exists and is
exact by
Lemmas \ref{lemma-extension-by-zero} and
\ref{lemma-extension-by-zero-exact}.
\end{enumerate}
\end{definition}

\noindent
As in the topological case, see
Sheaves, Section \ref{sheaves-section-open-immersions},
the extension by zero $j_{U!}$ functor is different from
extension by the empty set $j_{U!}$ defined on sheaves of sets.
Here is the lemma defining extension by zero.

\begin{lemma}
\label{lemma-extension-by-zero}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $U \in \Ob(\mathcal{C})$.
The restriction functor
$j_U^* : \textit{Mod}(\mathcal{O}) \to \textit{Mod}(\mathcal{O}_U)$
has a left adjoint
$j_{U!} : \textit{Mod}(\mathcal{O}_U) \to \textit{Mod}(\mathcal{O})$.
So
$$
\Mor_{\textit{Mod}(\mathcal{O}_U)}(\mathcal{G}, j_U^*\mathcal{F})
=
\Mor_{\textit{Mod}(\mathcal{O})}(j_{U!}\mathcal{G}, \mathcal{F})
$$
for $\mathcal{F} \in \Ob(\textit{Mod}(\mathcal{O}))$
and $\mathcal{G} \in \Ob(\textit{Mod}(\mathcal{O}_U))$.
Moreover, the extension by zero $j_{U!}\mathcal{G}$ of $\mathcal{G}$
is the sheaf associated to the presheaf
$$
V
\longmapsto
\bigoplus\nolimits_{\varphi \in \Mor_\mathcal{C}(V, U)}
\mathcal{G}(V \xrightarrow{\varphi} U)
$$
with obvious restriction mappings and an obvious $\mathcal{O}$-module
structure.
\end{lemma}

\begin{proof}
The $\mathcal{O}$-module structure on the presheaf is defined as
follows. If $f \in \mathcal{O}(V)$ and
$s \in \mathcal{G}(V \xrightarrow{\varphi} U)$, then
we define $f \cdot s = fs$ where
$f \in \mathcal{O}_U(\varphi : V \to U) = \mathcal{O}(V)$
(because $\mathcal{O}_U$ is the restriction of $\mathcal{O}$ to
$\mathcal{C}/U$).

\medskip\noindent
Similarly, let $\alpha : \mathcal{G} \to \mathcal{F}|_U$ be a
morphism of $\mathcal{O}_U$-modules. In this case we can define
a map from the presheaf of the lemma into $\mathcal{F}$ by mapping
$$
\bigoplus\nolimits_{\varphi \in \Mor_\mathcal{C}(V, U)}
\mathcal{G}(V \xrightarrow{\varphi} U)
\longrightarrow
\mathcal{F}(V)
$$
by the rule that $s \in \mathcal{G}(V \xrightarrow{\varphi} U)$
maps to $\alpha(s) \in \mathcal{F}(V)$. It is clear that this is
$\mathcal{O}$-linear, and hence induces a morphism of
$\mathcal{O}$-modules $\alpha' : j_{U!}\mathcal{G} \to \mathcal{F}$
by the properties of sheafification of modules
(Lemma \ref{lemma-sheafification-presheaf-modules}).

\medskip\noindent
Conversely, let $\beta : j_{U!}\mathcal{G} \to \mathcal{F}$
by a map of $\mathcal{O}$-modules.
Recall from Sites, Section \ref{sites-section-localize}
that there exists an extension by the empty set
$j^{Sh}_{U!} : \Sh(\mathcal{C}/U) \to \Sh(\mathcal{C})$
on sheaves of sets which is left adjoint to $j_U^{-1}$.
Moreover, $j^{Sh}_{U!}\mathcal{G}$ is the sheaf associated to the presheaf
$$
V
\longmapsto
\coprod\nolimits_{\varphi \in \Mor_\mathcal{C}(V, U)}
\mathcal{G}(V \xrightarrow{\varphi} U)
$$
Hence there is a natural map
$j^{Sh}_{U!}\mathcal{G} \to j_{U!}\mathcal{G}$ of sheaves of sets.
Hence precomposing $\beta$ by this map we get a map of sheaves of sets
$j^{Sh}_{U!}\mathcal{G} \to \mathcal{F}$ which by adjunction corresponds
to a map of sheaves of sets $\beta' : \mathcal{G} \to \mathcal{F}|_U$.
We claim that $\beta'$ is $\mathcal{O}_U$-linear. Namely, suppose
that $\varphi : V \to U$ is an object of $\mathcal{C}/U$ and that
$s, s' \in \mathcal{G}(\varphi : V \to U)$, and
$f \in \mathcal{O}(V) = \mathcal{O}_U(\varphi : V \to U)$.
Then by the discussion above we see that
$\beta'(s + s')$, resp.\  $\beta'(fs)$ in $\mathcal{F}|_U(\varphi : V \to U)$
correspond to $\beta(s + s')$, resp.\ $\beta(fs)$ in
$\mathcal{F}(V)$. Since $\beta$ is a homomorphism we conclude.

\medskip\noindent
To conclude the proof of the lemma we have to show that the constructions
$\alpha \mapsto \alpha'$ and $\beta \mapsto \beta'$ are mutually inverse.
We omit the verifications.
\end{proof}

\noindent
Note that we have in the situation of
Definition \ref{definition-localize-ringed-site} we have
\begin{equation}
\label{equation-map-lower-shriek-OU-into-module}
\Hom_\mathcal{O}(j_{U!}\mathcal{O}_U, \mathcal{F}) =
\Hom_{\mathcal{O}_U}(\mathcal{O}_U, j_U^*\mathcal{F}) =
\mathcal{F}(U)
\end{equation}
for every $\mathcal{O}$-module $\mathcal{F}$. Namely, the first equality
holds by the adjointness of $j_{U!}$ and $j_U^*$ and the second because
$\Hom_{\mathcal{O}_U}(\mathcal{O}_U, j_U^*\mathcal{F}) =
j_U^*\mathcal{F}(U/U) = \mathcal{F}|_U(U/U) = \mathcal{F}(U)$.

\begin{lemma}
\label{lemma-extension-by-zero-exact}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $U \in \Ob(\mathcal{C})$.
The functor
$j_{U!} : \textit{Mod}(\mathcal{O}_U) \to \textit{Mod}(\mathcal{O})$
is exact.
\end{lemma}

\begin{proof}
Since $j_{U!}$ is a left adjoint to $j_U^*$ we see that it is right exact
(see
Categories, Lemma \ref{categories-lemma-exact-adjoint}
and
Homology, Section \ref{homology-section-functors}).
Hence it suffices to show that if $\mathcal{G}_1 \to \mathcal{G}_2$
is an injective map of $\mathcal{O}_U$-modules, then
$j_{U!}\mathcal{G}_1 \to j_{U!}\mathcal{G}_2$ is injective.
The map on sections of presheaves over an object $V$
(as in Lemma \ref{lemma-extension-by-zero}) is the map
$$
\bigoplus\nolimits_{\varphi \in \Mor_\mathcal{C}(V, U)}
\mathcal{G}_1(V \xrightarrow{\varphi} U)
\longrightarrow
\bigoplus\nolimits_{\varphi \in \Mor_\mathcal{C}(V, U)}
\mathcal{G}_2(V \xrightarrow{\varphi} U)
$$
which is injective by assumption. Since sheafification is exact by
Lemma \ref{lemma-sheafification-exact}
we conclude $j_{U!}\mathcal{G}_1 \to j_{U!}\mathcal{G}_2$ is injective and
we win.
\end{proof}

\begin{lemma}
\label{lemma-j-shriek-reflects-exactness}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $U \in \Ob(\mathcal{C})$. A complex of $\mathcal{O}_U$-modules
$\mathcal{G}_1 \to \mathcal{G}_2 \to \mathcal{G}_3$ is exact
if and only if
$j_{U!}\mathcal{G}_1 \to j_{U!}\mathcal{G}_2 \to j_{U!}\mathcal{G}_3$
is exact as a sequence of $\mathcal{O}$-modules.
\end{lemma}

\begin{proof}
We already know that $j_{U!}$ is exact, see
Lemma \ref{lemma-extension-by-zero-exact}.
Thus it suffices to show that
$j_{U!} :  \textit{Mod}(\mathcal{O}_U) \to \textit{Mod}(\mathcal{O})$
reflects injections and surjections.

\medskip\noindent
For every $\mathcal{G}$ in $\textit{Mod}(\mathcal{O}_U)$
we have the unit $\mathcal{G} \to j_U^*j_{U!}\mathcal{G}$
of the adjunction. We claim this map is an injection of sheaves.
Namely, looking at the construction of Lemma \ref{lemma-extension-by-zero}
we see that this map is the sheafification of the rule sending the object
$V/U$ of $\mathcal{C}/U$ to the injective map
$$
\mathcal{G}(V/U) \longrightarrow
\bigoplus\nolimits_{\varphi \in \Mor_\mathcal{C}(V, U)}
\mathcal{G}(V \xrightarrow{\varphi} U)
$$
given by the inclusion of the summand corresponding to the structure
morphism $V \to U$. Since sheafification is exact the claim follows.
Some details omitted.

\medskip\noindent
If $\mathcal{G} \to \mathcal{G}'$ is a map of $\mathcal{O}_U$-modules with
$j_{U!}\mathcal{G} \to j_{U!}\mathcal{G}'$ injective,
then $j_U^*j_{U!}\mathcal{G} \to j_U^*j_{U!}\mathcal{G}'$ is injective
(restriction is exact), hence
$\mathcal{G} \to j_U^*j_{U!}\mathcal{G}'$ is injective, hence
$\mathcal{G} \to \mathcal{G}'$ is injective.
We conclude that $j_{U!}$ reflects injections.

\medskip\noindent
Let $a : \mathcal{G} \to \mathcal{G}'$ be a map of $\mathcal{O}_U$-modules
such that $j_{U!}\mathcal{G} \to j_{U!}\mathcal{G}'$ is surjective.
Let $\mathcal{H}$ be the cokernel of $a$.
Then $j_{U!}\mathcal{H} = 0$ as $j_{U!}$ is exact.
By the above the map $\mathcal{H} \to j^*_U j_{U!}\mathcal{H}$
is injective. Hence $\mathcal{H} = 0$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-relocalize}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $f : V \to U$ be a morphism of $\mathcal{C}$.
Then there exists a commutative diagram
$$
\xymatrix{
(\Sh(\mathcal{C}/V), \mathcal{O}_V)
\ar[rd]_{(j_V, j_V^\sharp)} \ar[rr]_{(j, j^\sharp)} & &
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\ar[ld]^{(j_U, j_U^\sharp)} \\
& (\Sh(\mathcal{C}), \mathcal{O}) &
}
$$
of ringed topoi. Here $(j, j^\sharp)$ is the localization morphism
associated to the object $V/U$ of the ringed site
$(\mathcal{C}/V, \mathcal{O}_V)$.
\end{lemma}

\begin{proof}
The only thing to check is that
$j_V^\sharp = j^\sharp \circ j^{-1}(j_U^\sharp)$,
since everything else follows directly from
Sites, Lemma \ref{sites-lemma-relocalize} and
Sites, Equation (\ref{sites-equation-relocalize}).
We omit the verification of the equality.
\end{proof}

\begin{remark}
\label{remark-localize-shriek-equal}
In the situation of Lemma \ref{lemma-extension-by-zero}
the diagram
$$
\xymatrix{
\textit{Mod}(\mathcal{O}_U) \ar[r]_{j_{U!}} \ar[d]_{forget} &
\textit{Mod}(\mathcal{O}_\mathcal{C}) \ar[d]^{forget} \\
\textit{Ab}(\mathcal{C}/U) \ar[r]^{j^{Ab}_{U!}} &
\textit{Ab}(\mathcal{C})
}
$$
commutes. This is clear from the explicit description of the functor
$j_{U!}$ in the lemma.
\end{remark}

\begin{remark}
\label{remark-localize-presheaves}
Localization and presheaves of modules; see
Sites, Remark \ref{sites-remark-localize-presheaves}.
Let $\mathcal{C}$ be a category.
Let $\mathcal{O}$ be a presheaf of rings.
Let $U$ be an object of $\mathcal{C}$.
Strictly speaking the functors $j_U^*$, $j_{U*}$ and $j_{U!}$
have not been defined for presheaves of $\mathcal{O}$-modules.
But of course, we can think of a presheaf as a sheaf for the
chaotic topology on $\mathcal{C}$ (see
Sites, Examples \ref{sites-example-indiscrete}).
Hence we also obtain a functor
$$
j_U^* :
\textit{PMod}(\mathcal{O})
\longrightarrow
\textit{PMod}(\mathcal{O}_U)
$$
and functors
$$
j_{U*}, j_{U!} :
\textit{PMod}(\mathcal{O}_U)
\longrightarrow
\textit{PMod}(\mathcal{O})
$$
which are right, left adjoint to $j_U^*$. Inspecting the proof of
Lemma \ref{lemma-extension-by-zero} we see that $j_{U!}\mathcal{G}$
is the presheaf
$$
V \longmapsto
\bigoplus\nolimits_{\varphi \in \Mor_\mathcal{C}(V, U)}
\mathcal{G}(V \xrightarrow{\varphi} U)
$$
In addition the functor $j_{U!}$ is exact (by
Lemma \ref{lemma-extension-by-zero-exact} in the
case of the discrete topologies). Moreover, if $\mathcal{C}$
is actually a site, and $\mathcal{O}$ is actually a sheaf of rings,
then the diagram
$$
\xymatrix{
\textit{Mod}(\mathcal{O}_U) \ar[r]_{j_{U!}} \ar[d]_{forget} &
\textit{Mod}(\mathcal{O}) \\
\textit{PMod}(\mathcal{O}_U) \ar[r]^{j_{U!}} &
\textit{PMod}(\mathcal{O}) \ar[u]_{(\ )^\#}
}
$$
commutes.
\end{remark}

\begin{lemma}
\label{lemma-restrict-back}
Let $\mathcal{C}$ be a site. Let $U \in \Ob(\mathcal{C})$.
Assume that every $X$ in $\mathcal{C}$ has at most
one morphism to $U$. Let $\mathcal{F}$ be an abelian sheaf on $\mathcal{C}/U$.
The canonical maps $\mathcal{F} \to j_U^{-1}j_{U!}\mathcal{F}$
and $j_U^{-1}j_{U*}\mathcal{F} \to \mathcal{F}$ are
isomorphisms.
\end{lemma}

\begin{proof}
This is a special case of Lemma \ref{lemma-back-and-forth}
because the assumption on $U$ is equivalent to the fully faithfulness
of the localization functor $\mathcal{C}/U \to \mathcal{C}$.
\end{proof}









\section{Localization of morphisms of ringed sites}
\label{section-localize-morphisms}

\noindent
This section is the analogue of
Sites, Section \ref{sites-section-localize-morphisms}.

\begin{lemma}
\label{lemma-localize-morphism-ringed-sites}
Let
$(f, f^\sharp) :
(\mathcal{C}, \mathcal{O})
\longrightarrow
(\mathcal{D}, \mathcal{O}')$
be a morphism of ringed sites where $f$ is given by the continuous
functor $u : \mathcal{D} \to \mathcal{C}$.
Let $V$ be an object of $\mathcal{D}$ and set $U = u(V)$.
Then there is a canonical map of sheaves of rings $(f')^\sharp$
such that the diagram of
Sites, Lemma \ref{sites-lemma-localize-morphism}
is turned into a commutative diagram of ringed topoi
$$
\xymatrix{
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\ar[rr]_{(j_U, j_U^\sharp)} \ar[d]_{(f', (f')^\sharp)} & &
(\Sh(\mathcal{C}), \mathcal{O})
\ar[d]^{(f, f^\sharp)} \\
(\Sh(\mathcal{D}/V), \mathcal{O}'_V)
\ar[rr]^{(j_V, j_V^\sharp)} & &
(\Sh(\mathcal{D}), \mathcal{O}').
}
$$
Moreover, in this situation we have $f'_*j_U^{-1} = j_V^{-1}f_*$
and $f'_*j_U^* = j_V^*f_*$.
\end{lemma}

\begin{proof}
Just take $(f')^\sharp$ to be
$$
(f')^{-1}\mathcal{O}'_V =
(f')^{-1}j_V^{-1}\mathcal{O}' =
j_U^{-1}f^{-1}\mathcal{O}' \xrightarrow{j_U^{-1}f^\sharp}
j_U^{-1}\mathcal{O} = \mathcal{O}_U
$$
and everything else follows from
Sites, Lemma \ref{sites-lemma-localize-morphism}.
(Note that $j^{-1} = j^*$ on sheaves of modules if $j$ is a localization
morphism, hence the first equality of functors implies the second.)
\end{proof}

\begin{lemma}
\label{lemma-relocalize-morphism-ringed-sites}
Let
$(f, f^\sharp) :
(\mathcal{C}, \mathcal{O})
\longrightarrow
(\mathcal{D}, \mathcal{O}')$
be a morphism of ringed sites where $f$ is given by the continuous
functor $u : \mathcal{D} \to \mathcal{C}$.
Let $V \in \Ob(\mathcal{D})$, $U \in \Ob(\mathcal{C})$
and $c : U \to u(V)$ a morphism of $\mathcal{C}$.
There exists a commutative diagram of ringed topoi
$$
\xymatrix{
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\ar[rr]_{(j_U, j_U^\sharp)} \ar[d]_{(f_c, f_c^\sharp)} & &
(\Sh(\mathcal{C}), \mathcal{O}) \ar[d]^{(f, f^\sharp)} \\
(\Sh(\mathcal{D}/V), \mathcal{O}'_V)
\ar[rr]^{(j_V, j_V^\sharp)} & &
(\Sh(\mathcal{D}), \mathcal{O}').
}
$$
The morphism $(f_c, f_c^\sharp)$
is equal to the composition of the morphism
$$
(f', (f')^\sharp) :
(\Sh(\mathcal{C}/u(V)), \mathcal{O}_{u(V)})
\longrightarrow
(\Sh(\mathcal{D}/V), \mathcal{O}'_V)
$$
of
Lemma \ref{lemma-localize-morphism-ringed-sites}
and the morphism
$$
(j, j^\sharp) :
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\to
(\Sh(\mathcal{C}/u(V)), \mathcal{O}_{u(V)})
$$
of
Lemma \ref{lemma-relocalize}.
Given any morphisms $b : V' \to V$, $a : U' \to U$ and
$c' : U' \to u(V')$ such that
$$
\xymatrix{
U' \ar[r]_-{c'} \ar[d]_a & u(V') \ar[d]^{u(b)} \\
U \ar[r]^-c & u(V)
}
$$
commutes, then the following diagram of ringed topoi
$$
\xymatrix{
(\Sh(\mathcal{C}/U'), \mathcal{O}_{U'})
\ar[rr]_{(j_{U'/U}, j_{U'/U}^\sharp)} \ar[d]_{(f_{c'}, f_{c'}^\sharp)} & &
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\ar[d]^{(f_c, f_c^\sharp)} \\
(\Sh(\mathcal{D}/V'), \mathcal{O}'_{V'})
\ar[rr]^{(j_{V'/V}, j_{V'/V}^\sharp)} & &
(\Sh(\mathcal{D}/V), \mathcal{O}'_{V'})
}
$$
commutes.
\end{lemma}

\begin{proof}
On the level of morphisms of topoi this is
Sites, Lemma \ref{sites-lemma-relocalize-morphism}.
To check that the diagrams commute as morphisms of ringed topoi use
Lemmas \ref{lemma-relocalize} and
\ref{lemma-localize-morphism-ringed-sites}
exactly as in the proof of
Sites, Lemma \ref{sites-lemma-relocalize-morphism}.
\end{proof}
















\section{Localization of ringed topoi}
\label{section-localize-ringed-topoi}

\noindent
This section is the analogue of
Sites, Section \ref{sites-section-localize-topoi}
in the setting of ringed topoi.

\begin{lemma}
\label{lemma-localize-ringed-topos}
Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a ringed topos.
Let $\mathcal{F} \in \Sh(\mathcal{C})$ be a sheaf.
For a sheaf $\mathcal{H}$ on $\mathcal{C}$ denote
$\mathcal{H}_\mathcal{F}$ the sheaf $\mathcal{H} \times \mathcal{F}$
seen as an object of the category $\Sh(\mathcal{C})/\mathcal{F}$.
The pair
$(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})$
is a ringed topos and there is a canonical morphism of ringed topoi
$$
(j_\mathcal{F}, j_\mathcal{F}^\sharp) :
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\longrightarrow
(\Sh(\mathcal{C}), \mathcal{O})
$$
which is a localization as in
Section \ref{section-localize}
such that
\begin{enumerate}
\item the functor $j_\mathcal{F}^{-1}$ is the functor
$\mathcal{H} \mapsto \mathcal{H}_\mathcal{F}$,
\item the functor $j_\mathcal{F}^*$ is the functor
$\mathcal{H} \mapsto \mathcal{H}_\mathcal{F}$,
\item the functor $j_{\mathcal{F}!}$ on sheaves of sets is the forgetful
functor $\mathcal{G}/\mathcal{F} \mapsto \mathcal{G}$,
\item the functor $j_{\mathcal{F}!}$ on sheaves of modules associates
to the $\mathcal{O}_\mathcal{F}$-module
$\varphi : \mathcal{G} \to \mathcal{F}$ the $\mathcal{O}$-module
which is the sheafification of the presheaf
$$
V \longmapsto
\bigoplus\nolimits_{s \in \mathcal{F}(V)}
\{\sigma \in \mathcal{G}(V) \mid \varphi(\sigma) = s \}
$$
for $V \in \Ob(\mathcal{C})$.
\end{enumerate}
\end{lemma}

\begin{proof}
By
Sites, Lemma \ref{sites-lemma-localize-topos}
we see that $\Sh(\mathcal{C})/\mathcal{F}$ is a topos
and that (1) and (3) are true. In particular this shows that
$j_\mathcal{F}^{-1}\mathcal{O} = \mathcal{O}_\mathcal{F}$
and shows that $\mathcal{O}_\mathcal{F}$ is a sheaf of rings.
Thus we may choose the map $j_\mathcal{F}^\sharp$ to be the identity,
in particular we see that (2) is true.
Moreover, the proof of
Sites, Lemma \ref{sites-lemma-localize-topos}
shows that we may assume $\mathcal{C}$ is a site with all finite limits
and a subcanonical topology and that $\mathcal{F} = h_U$ for some object
$U$ of $\mathcal{C}$.
Then (4) follows from the description of $j_{\mathcal{F}!}$ in
Lemma \ref{lemma-extension-by-zero}.
Alternatively one could show directly that the functor described
in (4) is a left adjoint to $j_\mathcal{F}^*$.
\end{proof}

\begin{definition}
\label{definition-localize-ringed-topos}
Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a ringed topos.
Let $\mathcal{F} \in \Sh(\mathcal{C})$.
\begin{enumerate}
\item The ringed topos
$(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})$
is called the
{\it localization of the ringed topos
$(\Sh(\mathcal{C}), \mathcal{O})$ at $\mathcal{F}$}.
\item The morphism of ringed topoi
$(j_\mathcal{F}, j_\mathcal{F}^\sharp) :
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\to
(\Sh(\mathcal{C}), \mathcal{O})$ of
Lemma \ref{lemma-localize-ringed-topos}
is called the {\it localization morphism}.
\end{enumerate}
\end{definition}

\noindent
We continue the tradition, established in the chapter on sites, that we
check the localization constructions on topoi are compatible with the
constructions of localization on sites, whenever this makes sense.

\begin{lemma}
\label{lemma-localize-compare}
With
$(\Sh(\mathcal{C}), \mathcal{O})$ and
$\mathcal{F} \in \Sh(\mathcal{C})$ as in
Lemma \ref{lemma-localize-ringed-topos}.
If $\mathcal{F} = h_U^\#$ for some object $U$ of $\mathcal{C}$
then via the identification
$\Sh(\mathcal{C}/U) = \Sh(\mathcal{C})/h_U^\#$ of
Sites, Lemma \ref{sites-lemma-essential-image-j-shriek}
we have
\begin{enumerate}
\item canonically $\mathcal{O}_U = \mathcal{O}_\mathcal{F}$, and
\item with these identifications
we have $(j_\mathcal{F}, j_\mathcal{F}^\sharp) = (j_U, j_U^\sharp)$.
\end{enumerate}
\end{lemma}

\begin{proof}
The assertion for underlying topoi is
Sites, Lemma \ref{sites-lemma-localize-compare}.
Note that $\mathcal{O}_U$ is the restriction of $\mathcal{O}$
which by
Sites, Lemma \ref{sites-lemma-compute-j-shriek-restrict}
corresponds to $\mathcal{O} \times h_U^\#$ under the equivalence of
Sites, Lemma \ref{sites-lemma-essential-image-j-shriek}.
By definition of $\mathcal{O}_\mathcal{F}$ we get (1).
What's left is to prove that $j_\mathcal{F}^\sharp = j_U^\sharp$
under this identification. We omit the verification.
\end{proof}

\noindent
Localization is functorial in the following two ways:
We can ``relocalize'' a localization (see
Lemma \ref{lemma-relocalize-ringed-topos})
or we can given a morphism of ringed topoi, localize upstairs at
the inverse image of a sheaf downstairs and get a commutative
diagram of ringed topoi (see
Lemma \ref{lemma-localize-morphism-ringed-topoi}).

\begin{lemma}
\label{lemma-relocalize-ringed-topos}
Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a ringed topos.
If $s : \mathcal{G} \to \mathcal{F}$ is a morphism of sheaves
on $\mathcal{C}$ then there exists a natural commutative diagram of
morphisms of ringed topoi
$$
\xymatrix{
(\Sh(\mathcal{C})/\mathcal{G}, \mathcal{O}_\mathcal{G})
\ar[rd]_{(j_\mathcal{G}, j_\mathcal{G}^\sharp)} \ar[rr]_{(j, j^\sharp)} & &
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\ar[ld]^{(j_\mathcal{F}, j_\mathcal{F}^\sharp)} \\
& (\Sh(\mathcal{C}), \mathcal{O}) &
}
$$
where $(j, j^\sharp)$ is the localization morphism of the ringed topos
$(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})$
at the object $\mathcal{G}/\mathcal{F}$.
\end{lemma}

\begin{proof}
All assertions follow from
Sites, Lemma \ref{sites-lemma-relocalize-topos}
except the assertion that
$j_\mathcal{G}^\sharp = j^\sharp \circ j^{-1}(j_\mathcal{F}^\sharp)$.
We omit the verification.
\end{proof}

\begin{lemma}
\label{lemma-relocalize-compare}
With $(\Sh(\mathcal{C}), \mathcal{O})$,
$s : \mathcal{G} \to \mathcal{F}$ as in
Lemma \ref{lemma-relocalize-ringed-topos}.
If there exist a morphism $f : V \to U$ of $\mathcal{C}$
such that $\mathcal{G} = h_V^\#$ and $\mathcal{F} = h_U^\#$
and $s$ is induced by $f$, then the
diagrams of
Lemma \ref{lemma-relocalize}
and
Lemma \ref{lemma-relocalize-ringed-topos}
agree via the identifications
$(j_\mathcal{F}, j_\mathcal{F}^\sharp) = (j_U, j_U^\sharp)$
and
$(j_\mathcal{G}, j_\mathcal{G}^\sharp) = (j_V, j_V^\sharp)$
of
Lemma \ref{lemma-localize-compare}.
\end{lemma}

\begin{proof}
All assertions follow from
Sites, Lemma \ref{sites-lemma-relocalize-compare}
except for the assertion that the two maps $j^\sharp$
agree. This holds since in both cases the map
$j^\sharp$ is simply the identity. Some details omitted.
\end{proof}










\section{Localization of morphisms of ringed topoi}
\label{section-localize-morphisms-ringed-topoi}

\noindent
This section is the analogue of
Sites, Section \ref{sites-section-localize-morphisms-topoi}.

\begin{lemma}
\label{lemma-localize-morphism-ringed-topoi}
Let
$$
f :
(\Sh(\mathcal{C}), \mathcal{O})
\longrightarrow
(\Sh(\mathcal{D}), \mathcal{O}')
$$
be a morphism of ringed topoi. Let $\mathcal{G}$ be a sheaf on $\mathcal{D}$.
Set $\mathcal{F} = f^{-1}\mathcal{G}$.
Then there exists a commutative diagram of ringed topoi
$$
\xymatrix{
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\ar[rr]_{(j_\mathcal{F}, j_\mathcal{F}^\sharp)}
\ar[d]_{(f', (f')^\sharp)} & &
(\Sh(\mathcal{C}), \mathcal{O}) \ar[d]^{(f, f^\sharp)} \\
(\Sh(\mathcal{D})/\mathcal{G}, \mathcal{O}'_\mathcal{G})
\ar[rr]^{(j_\mathcal{G}, j_\mathcal{G}^\sharp)} & &
(\Sh(\mathcal{D}), \mathcal{O}')
}
$$
We have $f'_*j_\mathcal{F}^{-1} = j_\mathcal{G}^{-1}f_*$
and $f'_*j_\mathcal{F}^* = j_\mathcal{G}^*f_*$. Moreover, the
morphism $f'$ is characterized by the rule
$$
(f')^{-1}(\mathcal{H} \xrightarrow{\varphi} \mathcal{G})
=
(f^{-1}\mathcal{H} \xrightarrow{f^{-1}\varphi} \mathcal{F}).
$$
\end{lemma}

\begin{proof}
By
Sites, Lemma \ref{sites-lemma-localize-morphism-topoi}
we have the diagram of underlying topoi, the
equality $f'_*j_\mathcal{F}^{-1} = j_\mathcal{G}^{-1}f_*$, and
the description of $(f')^{-1}$.
To define $(f')^\sharp$ we use the map
$$
(f')^\sharp :
\mathcal{O}'_\mathcal{G} =
j_\mathcal{G}^{-1} \mathcal{O}'
\xrightarrow{j_\mathcal{G}^{-1}f^\sharp}
j_\mathcal{G}^{-1} f_*\mathcal{O} =
f'_* j_\mathcal{F}^{-1}\mathcal{O} =
f'_* \mathcal{O}_\mathcal{F}
$$
or equivalently the map
$$
(f')^\sharp :
(f')^{-1}\mathcal{O}'_\mathcal{G} =
(f')^{-1}j_\mathcal{G}^{-1} \mathcal{O}' =
j_\mathcal{F}^{-1}f^{-1}\mathcal{O}'
\xrightarrow{j_\mathcal{F}^{-1}f^\sharp}
j_\mathcal{F}^{-1} \mathcal{O} =
\mathcal{O}_\mathcal{F}.
$$
We omit the verification that these two maps are indeed adjoint
to each other. The second construction of $(f')^\sharp$ shows that
the diagram commutes in the $2$-category of ringed topoi (as the
maps $j_\mathcal{F}^\sharp$ and $j_\mathcal{G}^\sharp$ are identities).
Finally, the equality $f'_*j_\mathcal{F}^* = j_\mathcal{G}^*f_*$
follows from the equality
$f'_*j_\mathcal{F}^{-1} = j_\mathcal{G}^{-1}f_*$
and the fact that pullbacks of sheaves of modules and sheaves of sets agree,
see
Lemma \ref{lemma-localize-ringed-topos}.
\end{proof}

\begin{lemma}
\label{lemma-localize-morphism-compare}
Let
$$
f :
(\Sh(\mathcal{C}), \mathcal{O})
\longrightarrow
(\Sh(\mathcal{D}), \mathcal{O}')
$$
be a morphism of ringed topoi.
Let $\mathcal{G}$ be a sheaf on $\mathcal{D}$.
Set $\mathcal{F} = f^{-1}\mathcal{G}$.
If $f$ is given by a continuous functor $u : \mathcal{D} \to \mathcal{C}$
and $\mathcal{G} = h_V^\#$, then the commutative diagrams of
Lemma \ref{lemma-localize-morphism-ringed-sites}
and
Lemma \ref{lemma-localize-morphism-ringed-topoi}
agree via the identifications of
Lemma \ref{lemma-localize-compare}.
\end{lemma}

\begin{proof}
At the level of morphisms of topoi this is
Sites, Lemma \ref{sites-lemma-localize-morphism-compare}.
This works also on the level of morphisms of ringed topoi since
the formulas defining $(f')^\sharp$ in the proofs of
Lemma \ref{lemma-localize-morphism-ringed-sites}
and
Lemma \ref{lemma-localize-morphism-ringed-topoi}
agree.
\end{proof}

\begin{lemma}
\label{lemma-relocalize-morphism-ringed-topoi}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O})
\to
(\Sh(\mathcal{D}), \mathcal{O}')$
be a morphism of ringed topoi.
Let $\mathcal{G}$ be a sheaf on $\mathcal{D}$,
let $\mathcal{F}$ be a sheaf on $\mathcal{C}$,
and let $s : \mathcal{F} \to f^{-1}\mathcal{G}$ a morphism of sheaves.
There exists a commutative diagram of ringed topoi
$$
\xymatrix{
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\ar[rr]_{(j_\mathcal{F}, j_\mathcal{F}^\sharp)}
\ar[d]_{(f_c, f_c^\sharp)} & &
(\Sh(\mathcal{C}), \mathcal{O})
\ar[d]^{(f, f^\sharp)} \\
(\Sh(\mathcal{D})/\mathcal{G}, \mathcal{O}'_\mathcal{G})
\ar[rr]^{(j_\mathcal{G}, j_\mathcal{G}^\sharp)} & &
(\Sh(\mathcal{D}), \mathcal{O}').
}
$$
The morphism $(f_s, f_s^\sharp)$
is equal to the composition of the morphism
$$
(f', (f')^\sharp) :
(\Sh(\mathcal{C})/f^{-1}\mathcal{G}, \mathcal{O}_{f^{-1}\mathcal{G}})
\longrightarrow
(\Sh(\mathcal{D})/{\mathcal{G}}, \mathcal{O}'_\mathcal{G})
$$
of
Lemma \ref{lemma-localize-morphism-ringed-topoi}
and the morphism
$$
(j, j^\sharp) :
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\to
(\Sh(\mathcal{C})/f^{-1}\mathcal{G}, \mathcal{O}_{f^{-1}\mathcal{G}})
$$
of
Lemma \ref{lemma-relocalize-ringed-topos}.
Given any morphisms $b : \mathcal{G}' \to \mathcal{G}$,
$a : \mathcal{F}' \to \mathcal{F}$, and
$s' : \mathcal{F}' \to f^{-1}\mathcal{G}'$ such that
$$
\xymatrix{
\mathcal{F}' \ar[r]_-{s'} \ar[d]_a &
f^{-1}\mathcal{G}' \ar[d]^{f^{-1}b} \\
\mathcal{F} \ar[r]^-s &
f^{-1}\mathcal{G}
}
$$
commutes, then the following diagram of ringed topoi
$$
\xymatrix{
(\Sh(\mathcal{C})/\mathcal{F}', \mathcal{O}_{\mathcal{F}'})
\ar[rr]_{(j_{\mathcal{F}'/\mathcal{F}}, j_{\mathcal{F}'/\mathcal{F}}^\sharp)}
\ar[d]_{(f_{s'}, f_{s'}^\sharp)} & &
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\ar[d]^{(f_s, f_s^\sharp)} \\
(\Sh(\mathcal{D})/\mathcal{G}', \mathcal{O}'_{\mathcal{G}'})
\ar[rr]^{(j_{\mathcal{G}'/\mathcal{G}}, j_{\mathcal{G}'/\mathcal{G}}^\sharp)}
& &
(\Sh(\mathcal{D})/\mathcal{G}, \mathcal{O}'_{\mathcal{G}'})
}
$$
commutes.
\end{lemma}

\begin{proof}
On the level of morphisms of topoi this is
Sites, Lemma \ref{sites-lemma-relocalize-morphism-topoi}.
To check that the diagrams commute as morphisms of ringed topoi use
the commutative diagrams of
Lemmas \ref{lemma-relocalize-ringed-topos} and
\ref{lemma-localize-morphism-ringed-topoi}.
\end{proof}

\begin{lemma}
\label{lemma-relocalize-morphism-compare}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O})
\to
(\Sh(\mathcal{D}), \mathcal{O}')$,
$s : \mathcal{F} \to f^{-1}\mathcal{G}$ be as in
Lemma \ref{lemma-relocalize-morphism-ringed-topoi}.
If $f$ is given by a continuous functor
$u : \mathcal{D} \to \mathcal{C}$
and $\mathcal{G} = h_V^\#$,
$\mathcal{F} = h_U^\#$ and $s$ comes from a morphism
$c : U \to u(V)$, then
the commutative diagrams of
Lemma \ref{lemma-relocalize-morphism-ringed-sites}
and
Lemma \ref{lemma-relocalize-morphism-ringed-topoi}
agree via the identifications of
Lemma \ref{lemma-localize-compare}.
\end{lemma}

\begin{proof}
This is formal using
Lemmas \ref{lemma-relocalize-compare} and
\ref{lemma-localize-morphism-compare}.
\end{proof}

















\section{Local types of modules}
\label{section-local}

\noindent
According to our general strategy explained in Section \ref{section-intrinsic}
we first define the local types for sheaves of modules on a ringed site, and
then we immediately show that these types are intrinsic, hence make sense
for sheaves of modules on ringed topoi.

\begin{definition}
\label{definition-site-local}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}$-modules.
We will freely use the notions defined in
Definition \ref{definition-global}.
\begin{enumerate}
\item We say $\mathcal{F}$ is {\it locally free}
if for every object $U$ of $\mathcal{C}$ there exists a covering
$\{U_i \to U\}_{i \in I}$ of $\mathcal{C}$ such that each restriction
$\mathcal{F}|_{\mathcal{C}/U_i}$ is a free
$\mathcal{O}_{U_i}$-module.
\item We say $\mathcal{F}$ is {\it finite locally free}
if for every object $U$ of $\mathcal{C}$ there exists a covering
$\{U_i \to U\}_{i \in I}$ of $\mathcal{C}$ such that each restriction
$\mathcal{F}|_{\mathcal{C}/U_i}$ is a finite free
$\mathcal{O}_{U_i}$-module.
\item We say $\mathcal{F}$ is {\it locally generated by sections}
if for every object $U$ of $\mathcal{C}$ there exists a covering
$\{U_i \to U\}_{i \in I}$ of $\mathcal{C}$ such that each restriction
$\mathcal{F}|_{\mathcal{C}/U_i}$ is an
$\mathcal{O}_{U_i}$-module generated by global sections.
\item Given $r \geq 0$ we sat $\mathcal{F}$ is {\it locally generated
by $r$ sections} if for every object $U$ of $\mathcal{C}$ there exists
a covering $\{U_i \to U\}_{i \in I}$ of $\mathcal{C}$ such that each
restriction $\mathcal{F}|_{\mathcal{C}/U_i}$ is an
$\mathcal{O}_{U_i}$-module generated by $r$ global sections.
\item We say $\mathcal{F}$ is {\it of finite type}
if for every object $U$ of $\mathcal{C}$ there exists a covering
$\{U_i \to U\}_{i \in I}$ of $\mathcal{C}$ such that each restriction
$\mathcal{F}|_{\mathcal{C}/U_i}$ is an
$\mathcal{O}_{U_i}$-module generated by finitely many global sections.
\item We say $\mathcal{F}$ is {\it quasi-coherent}
if for every object $U$ of $\mathcal{C}$ there exists a covering
$\{U_i \to U\}_{i \in I}$ of $\mathcal{C}$ such that each restriction
$\mathcal{F}|_{\mathcal{C}/U_i}$ is an
$\mathcal{O}_{U_i}$-module which has a global presentation.
\item We say $\mathcal{F}$ is {\it of finite presentation}
if for every object $U$ of $\mathcal{C}$ there exists a covering
$\{U_i \to U\}_{i \in I}$ of $\mathcal{C}$ such that each restriction
$\mathcal{F}|_{\mathcal{C}/U_i}$ is an
$\mathcal{O}_{U_i}$-module which has a finite global presentation.
\item We say $\mathcal{F}$ is {\it coherent} if and only if
$\mathcal{F}$ is of finite type, and for every object
$U$ of $\mathcal{C}$ and any $s_1, \ldots, s_n \in \mathcal{F}(U)$
the kernel of the map
$\bigoplus_{i = 1, \ldots, n} \mathcal{O}_U \to \mathcal{F}|_U$
is of finite type on $(\mathcal{C}/U, \mathcal{O}_U)$.
\end{enumerate}
\end{definition}

\begin{lemma}
\label{lemma-special-locally-free}
Any of the properties (1) -- (8) of Definition \ref{definition-site-local}
is intrinsic (see discussion in Section \ref{section-intrinsic}).
\end{lemma}

\begin{proof}
Let $\mathcal{C}$, $\mathcal{D}$ be sites.
Let $u : \mathcal{C} \to \mathcal{D}$ be a special cocontinuous functor.
Let $\mathcal{O}$ be a sheaf of rings on $\mathcal{C}$.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}$-modules on $\mathcal{C}$.
Let $g : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$
be the equivalence of topoi associated to $u$.
Set $\mathcal{O}' = g_*\mathcal{O}$, and let
$g^\sharp : \mathcal{O}' \to g_*\mathcal{O}$ be the identity.
Finally, set $\mathcal{F}' = g_*\mathcal{F}$.
Let $\mathcal{P}_l$ be one of the properties (1) -- (7) listed in
Definition \ref{definition-site-local}.
(We will discuss the coherent case at the end of the proof.)
Let $\mathcal{P}_g$ denote the corresponding property listed in
Definition \ref{definition-global}. We have already seen that
$\mathcal{P}_g$ is intrinsic.
We have to show that
$\mathcal{P}_l(\mathcal{C}, \mathcal{O}, \mathcal{F})$
holds if and only if
$\mathcal{P}_l(\mathcal{D}, \mathcal{O}', \mathcal{F}')$
holds.

\medskip\noindent
Assume that $\mathcal{F}$ has $\mathcal{P}_l$.
Let $V$ be an object of $\mathcal{D}$.
One of the properties of a special cocontinuous functor is that there exists
a covering $\{u(U_i) \to V\}_{i \in I}$ in the site $\mathcal{D}$.
By assumption, for each $i$ there exists a covering
$\{U_{ij} \to U_i\}_{j \in J_i}$ in $\mathcal{C}$ such that
each restriction $\mathcal{F}|_{U_{ij}}$ is $\mathcal{P}_g$. By
Sites, Lemma \ref{sites-lemma-localize-special-cocontinuous}
we have commutative diagrams of ringed topoi
$$
\xymatrix{
(\Sh(\mathcal{C}/U_{ij}), \mathcal{O}_{U_{ij}}) \ar[r] \ar[d] &
(\Sh(\mathcal{C}), \mathcal{O}) \ar[d] \\
(\Sh(\mathcal{D}/u(U_{ij})), \mathcal{O}'_{u(U_{ij})}) \ar[r] &
(\Sh(\mathcal{D}), \mathcal{O}')
}
$$
where the vertical arrows are equivalences. Hence we conclude that
$\mathcal{F}'|_{u(U_{ij})}$ has property $\mathcal{P}_g$ also.
And moreover, $\{u(U_{ij}) \to V\}_{i \in I, j \in J_i}$ is a
covering of the site $\mathcal{D}$. Hence $\mathcal{F}'$ has
property $\mathcal{P}_l$.

\medskip\noindent
Assume that $\mathcal{F}'$ has $\mathcal{P}_l$.
Let $U$ be an object of $\mathcal{C}$.
By assumption, there exists a covering
$\{V_i \to u(U)\}_{i \in I}$ such that $\mathcal{F}'|_{V_i}$
has property $\mathcal{P}_g$. Because $u$ is cocontinuous we
can refine this covering by a family $\{u(U_j) \to u(U)\}_{j \in J}$
where $\{U_j \to U\}_{j \in J}$ is a covering in $\mathcal{C}$.
Say the refinement is given by $\alpha : J \to I$ and
$u(U_j) \to V_{\alpha(j)}$.
Restricting is transitive, i.e.,
$(\mathcal{F}'|_{V_{\alpha(j)}})|_{u(U_j)} = \mathcal{F}'|_{u(U_j)}$.
Hence by Lemma \ref{lemma-global-pullback} we see that
$\mathcal{F}'|_{u(U_j)}$ has property $\mathcal{P}_g$.
Hence the diagram
$$
\xymatrix{
(\Sh(\mathcal{C}/U_j), \mathcal{O}_{U_j}) \ar[r] \ar[d] &
(\Sh(\mathcal{C}), \mathcal{O}) \ar[d] \\
(\Sh(\mathcal{D}/u(U_j)), \mathcal{O}'_{u(U_j)})
\ar[r] &
(\Sh(\mathcal{D}), \mathcal{O}')
}
$$
where the vertical arrows are equivalences shows that $\mathcal{F}|_{U_j}$
has property $\mathcal{P}_g$ also. Thus $\mathcal{F}$ has
property $\mathcal{P}_l$ as desired.

\medskip\noindent
Finally, we prove the lemma in case
$\mathcal{P}_l = coherent$\footnote{The mechanics of this
are a bit awkward, and we suggest the reader skip this part of the proof.}.
Assume $\mathcal{F}$ is coherent. This implies that $\mathcal{F}$
is of finite type and hence $\mathcal{F}'$ is of finite type also by the
first part of the proof. Let $V$ be an object of $\mathcal{D}$ and let
$s_1, \ldots, s_n \in \mathcal{F}'(V)$. We have to show that the kernel
$\mathcal{K}'$ of
$\bigoplus_{j = 1, \ldots, n} \mathcal{O}_V \to \mathcal{F}'|_V$
is of finite type on $\mathcal{D}/V$. This means we have to show that
for any $V'/V$ there exists a covering $\{V'_i \to V'\}$ such that
$\mathcal{F}'|_{V'_i}$ is generated by finitely many sections.
Replacing $V$ by $V'$ (and restricting the sections $s_j$ to $V'$)
we reduce to the case where $V' = V$. Since $u$ is a special
cocontinuous functor, there exists a covering $\{u(U_i) \to V\}_{i \in I}$
in the site $\mathcal{D}$. Using the isomorphism of topoi
$\Sh(\mathcal{C}/U_i) = \Sh(\mathcal{D}/u(U_i))$
we see that $\mathcal{K}'|_{u(U_i)}$ corresponds to the kernel
$\mathcal{K}_i$ of a map
$\bigoplus_{j = 1, \ldots, n} \mathcal{O}_{U_i} \to \mathcal{F}|_{U_i}$.
Since $\mathcal{F}$ is coherent we see that $\mathcal{K}_i$
is of finite type. Hence we conclude (by the first part of the proof again)
that $\mathcal{K}|_{u(U_i)}$ is of finite type. Thus there exist coverings
$\{V_{il} \to u(U_i)\}$ such that $\mathcal{K}|_{V_{il}}$ is generated
by finitely many global sections. Since
$\{V_{il} \to V\}$ is a covering of $\mathcal{D}$ we conclude that
$\mathcal{K}$ is of finite type as desired.

\medskip\noindent
Assume $\mathcal{F}'$ is coherent. This implies that $\mathcal{F}'$
is of finite type and hence $\mathcal{F}$ is of finite type also by the
first part of the proof. Let $U$ be an object of $\mathcal{C}$, and let
$s_1, \ldots, s_n \in \mathcal{F}(U)$. We have to show that the kernel
$\mathcal{K}$ of
$\bigoplus_{j = 1, \ldots, n} \mathcal{O}_U \to \mathcal{F}|_U$
is of finite type on $\mathcal{C}/U$. Using the isomorphism of topoi
$\Sh(\mathcal{C}/U) = \Sh(\mathcal{D}/u(U))$
we see that $\mathcal{K}|_U$ corresponds to the kernel
$\mathcal{K}'$ of a map
$\bigoplus_{j = 1, \ldots, n} \mathcal{O}_{u(U)} \to \mathcal{F}'|_{u(U)}$.
As $\mathcal{F}'$ is coherent, we see that $\mathcal{K}'$ is of finite
type. Hence, by the first part of the proof again, we conclude
that $\mathcal{K}$ is of finite type.
\end{proof}

\noindent
Hence from now on we may refer to the properties of $\mathcal{O}$-modules
defined in Definition \ref{definition-site-local} without specifying a site.

\begin{lemma}
\label{lemma-local-final-object}
Let $(\Sh(\mathcal{C}), \mathcal{O})$
be a ringed topos. Let $\mathcal{F}$ be an $\mathcal{O}$-module.
Assume that the site $\mathcal{C}$ has a final object $X$.
Then
\begin{enumerate}
\item The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is locally free,
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$ such that
each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$ is a locally free
$\mathcal{O}_{X_i}$-module, and
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$ such that
each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$ is a free
$\mathcal{O}_{X_i}$-module.
\end{enumerate}
\item The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is finite locally free,
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is a finite locally free $\mathcal{O}_{X_i}$-module, and
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is a finite free $\mathcal{O}_{X_i}$-module.
\end{enumerate}
\item The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is locally generated by sections,
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is an $\mathcal{O}_{X_i}$-module locally generated by sections, and
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is an $\mathcal{O}_{X_i}$-module globally generated by sections.
\end{enumerate}
\item Given $r \geq 0$, the following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is locally generated by $r$ sections,
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is an $\mathcal{O}_{X_i}$-module locally generated by $r$ sections, and
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is an $\mathcal{O}_{X_i}$-module globally generated by $r$ sections.
\end{enumerate}
\item The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is of finite type,
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is an $\mathcal{O}_{X_i}$-module of finite type, and
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is an $\mathcal{O}_{X_i}$-module globally generated by finitely many sections.
\end{enumerate}
\item The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is quasi-coherent,
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is a quasi-coherent $\mathcal{O}_{X_i}$-module, and
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is an $\mathcal{O}_{X_i}$-module which has a global presentation.
\end{enumerate}
\item The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is of finite presentation,
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is an $\mathcal{O}_{X_i}$-module of finite presentation, and
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is an $\mathcal{O}_{X_i}$-module has a finite global presentation.
\end{enumerate}
\item The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is coherent, and
\item there exists a covering $\{X_i \to X\}$ in $\mathcal{C}$
such that each restriction $\mathcal{F}|_{\mathcal{C}/X_i}$
is a coherent $\mathcal{O}_{X_i}$-module.
\end{enumerate}
\end{enumerate}
\end{lemma}

\begin{proof}
In each case we have (a) $\Rightarrow (b)$. In each of the cases (1) - (6)
condition (b) implies condition (c) by axiom (2) of a site
(see Sites, Definition \ref{sites-definition-site})
and the definition of the local types of modules.
Suppose $\{X_i \to X\}$ is a covering.
Then for every object $U$ of $\mathcal{C}$ we get an
induced covering $\{X_i \times_X U \to U\}$. Moreover, the global
property for $\mathcal{F}|_{\mathcal{C}/X_i}$ in part (c) implies
the corresponding global property for
$\mathcal{F}|_{\mathcal{C}/X_i \times_X U}$ by
Lemma \ref{lemma-global-pullback}, hence the sheaf has property (a)
by definition. We omit the proof of (b) $\Rightarrow$ (a) in case (7).
\end{proof}

\begin{lemma}
\label{lemma-local-pullback}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi.
Let $\mathcal{F}$ be an $\mathcal{O}_\mathcal{D}$-module.
\begin{enumerate}
\item If $\mathcal{F}$ is locally free then $f^*\mathcal{F}$ is locally free.
\item If $\mathcal{F}$ is finite locally free then $f^*\mathcal{F}$ is
finite locally free.
\item If $\mathcal{F}$ is locally generated by sections
then $f^*\mathcal{F}$ is locally generated by sections.
\item If $\mathcal{F}$ is locally generated by $r$ sections
then $f^*\mathcal{F}$ is locally generated by $r$ sections.
\item If $\mathcal{F}$ is of finite type
then $f^*\mathcal{F}$ is of finite type.
\item If $\mathcal{F}$ is quasi-coherent then
$f^*\mathcal{F}$ is quasi-coherent.
\item If $\mathcal{F}$ is of finite presentation
then $f^*\mathcal{F}$ is of finite presentation.
\end{enumerate}
\end{lemma}

\begin{proof}
According to the discussion in Section \ref{section-intrinsic}
we need only check preservation under pullback for a morphism of ringed sites
$(f, f^\sharp) :
(\mathcal{C}, \mathcal{O}_\mathcal{C})
\to
(\mathcal{D}, \mathcal{O}_\mathcal{D})$
such that $f$ is given by a left exact, continuous functor
$u : \mathcal{D} \to \mathcal{C}$ between sites which have
all finite limits.
Let $\mathcal{G}$ be a sheaf of $\mathcal{O}_\mathcal{D}$-modules
which has one of the properties (1) -- (6) of
Definition \ref{definition-site-local}.
We know $\mathcal{D}$ has a final object $Y$ and $X = u(Y)$
is a final object for $\mathcal{C}$. By assumption we have
a covering $\{Y_i \to Y\}$ such that $\mathcal{G}|_{\mathcal{D}/Y_i}$
has the corresponding global property. Set $X_i = u(Y_i)$ so
that $\{X_i \to X\}$ is a covering in $\mathcal{C}$.
We get a commutative diagram of morphisms ringed sites
$$
\xymatrix{
(\mathcal{C}/X_i, \mathcal{O}_\mathcal{C}|_{X_i}) \ar[r] \ar[d] &
(\mathcal{C}, \mathcal{O}_\mathcal{C}) \ar[d] \\
(\mathcal{D}/Y_i, \mathcal{O}_\mathcal{D}|_{Y_i}) \ar[r] &
(\mathcal{D}, \mathcal{O}_\mathcal{D})
}
$$
by Sites, Lemma \ref{sites-lemma-localize-morphism-strong}.
Hence by Lemma \ref{lemma-global-pullback}
that $f^*\mathcal{G}|_{X_i}$ has the corresponding global
property. Hence we conclude that $\mathcal{G}$ has the local
property we started out with by Lemma \ref{lemma-local-final-object}.
\end{proof}







\section{Basic results on local types of modules}
\label{section-basics}

\noindent
Basic lemmas related to the definitions made above.

\begin{lemma}
\label{lemma-cokernel-finite-finite-presentation}
Let $(\mathcal{C},\mathcal{O})$ be a ringed site. Let $\mathcal{F}$ be a
finitely presented $\mathcal{O}$-module. Let
$\varphi : \mathcal{G} \to \mathcal{F}$ be a morphism of
$\mathcal{O}$-modules. If $\mathcal{G}$ is finite type, then
$\Coker(\varphi)$ is finitely presented.
\end{lemma}

\begin{proof}
Omitted. Hint: See Modules, Lemma
\ref{modules-lemma-cokernel-finite-finite-presentation}.
\end{proof}

\begin{lemma}
\label{lemma-kernel-surjection-finite-onto-finite-presentation}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\theta : \mathcal{G} \to \mathcal{F}$ be a surjective
$\mathcal{O}$-module map with $\mathcal{F}$ of finite presentation
and $\mathcal{G}$ of finite type. Then $\Ker(\theta)$ is of finite type.
\end{lemma}

\begin{proof}
Omitted. Hint: See Modules, Lemma
\ref{modules-lemma-kernel-surjection-finite-free-onto-finite-presentation}.
\end{proof}

\begin{lemma}
\label{lemma-chaotic-quasi-coherent}
Let $\mathcal{C}$ be a category viewed as a site with the chaotic
topology, see Sites, Example \ref{sites-example-indiscrete}. Let $\mathcal{O}$
be a sheaf of rings on $\mathcal{C}$ and let $\mathcal{F}$ be a sheaf
of $\mathcal{O}$-modules. Then $\mathcal{F}$ is quasi-coherent if
and only if for all $U \to V$ in $\mathcal{C}$ the canonical map
$$
\mathcal{F}(V) \otimes_{\mathcal{O}(V)} \mathcal{O}(U)
\longrightarrow
\mathcal{F}(U)
$$
is an isomorphism.
\end{lemma}

\begin{proof}
Assume $\mathcal{F}$ is quasi-coherent and let $U \to V$ be a morphism
of $\mathcal{C}$. Since every covering of $V$ is given by an isomorphism
we conclude from Definition \ref{definition-site-local}
that there exists a presentation
$$
\bigoplus\nolimits_{j \in J} \mathcal{O}_V \longrightarrow
\bigoplus\nolimits_{i \in I} \mathcal{O}_V \longrightarrow
\mathcal{F}|_{\mathcal{C}/V} \longrightarrow 0
$$
Since the topology on $\mathcal{C}$ is chaotic, taking sections over
any object of $\mathcal{C}$ is exact. We conclude that we obtain
a presentation
$$
\bigoplus\nolimits_{j \in J} \mathcal{O}(V) \longrightarrow
\bigoplus\nolimits_{i \in I} \mathcal{O}(V) \longrightarrow
\mathcal{F}(V) \longrightarrow 0
$$
of $\mathcal{F}(V)$ as an $\mathcal{O}(V)$-module and similarly for
$\mathcal{F}(U)$. This easily shows that the displayed map in the statement
of the lemma is an isomorphism.

\medskip\noindent
Assume the displayed map in the statement of the lemma is an isomorphism
for every morphism $U \to V$ in $\mathcal{C}$. Fix $V$ and choose a
presentation
$$
\bigoplus\nolimits_{j \in J} \mathcal{O}(V) \longrightarrow
\bigoplus\nolimits_{i \in I} \mathcal{O}(V) \longrightarrow
\mathcal{F}(V) \longrightarrow 0
$$
of $\mathcal{F}(V)$ as an $\mathcal{O}(V)$-module. Then the assumption
on $\mathcal{F}$ exactly means that the corresponding sequence
$$
\bigoplus\nolimits_{j \in J} \mathcal{O}_V \longrightarrow
\bigoplus\nolimits_{i \in I} \mathcal{O}_V \longrightarrow
\mathcal{F}|_{\mathcal{C}/V} \longrightarrow 0
$$
is exact and we conclude that $\mathcal{F}$ is quasi-coherent.
\end{proof}

\begin{lemma}
\label{lemma-chaotic-flat-quasi-coherent}
Let $\mathcal{C}$ be a category viewed as a site with the chaotic
topology, see Sites, Example \ref{sites-example-indiscrete}.
Let $\mathcal{O}$ be a sheaf of rings on $\mathcal{C}$.
Assume for all $U \to V$ in $\mathcal{C}$ the restriction map
$\mathcal{O}(V) \to \mathcal{O}(U)$ is a flat ring map.
Then the category of quasi-coherent $\mathcal{O}$-modules is
a weak Serre subcategory of $\textit{Mod}(\mathcal{O})$.
\end{lemma}

\begin{proof}
We will check the definition of a weak Serre subcategory, see
Homology, Definition \ref{homology-definition-serre-subcategory}.
To do this we will use the characterization of quasi-coherent modules given in
Lemma \ref{lemma-chaotic-quasi-coherent}.
Consider an exact sequence
$$
\mathcal{F}_0 \to \mathcal{F}_1 \to
\mathcal{F}_2 \to \mathcal{F}_3 \to
\mathcal{F}_4
$$
in $\textit{Mod}(\mathcal{O})$ with $\mathcal{F}_0$, $\mathcal{F}_1$,
$\mathcal{F}_3$, and $\mathcal{F}_4$ quasi-coherent. Let $U \to V$
be a morphism of $\mathcal{C}$ and consider the commutative diagram
$$
\xymatrix{
\mathcal{F}_0(V) \otimes_{\mathcal{O}(V)} \mathcal{O}(U) \ar[r] \ar[d] &
\mathcal{F}_1(V) \otimes_{\mathcal{O}(V)} \mathcal{O}(U) \ar[r] \ar[d] &
\mathcal{F}_2(V) \otimes_{\mathcal{O}(V)} \mathcal{O}(U) \ar[r] \ar[d] &
\mathcal{F}_3(V) \otimes_{\mathcal{O}(V)} \mathcal{O}(U) \ar[r] \ar[d] &
\mathcal{F}_4(V) \otimes_{\mathcal{O}(V)} \mathcal{O}(U) \ar[d] \\
\mathcal{F}_0(U) \ar[r] &
\mathcal{F}_1(U) \ar[r] &
\mathcal{F}_2(U) \ar[r] &
\mathcal{F}_3(U) \ar[r] &
\mathcal{F}_4(U)
}
$$
By assumption the vertical arrows with indices $0$, $1$, $3$, $4$
are isomorphisms. Since the topology on $\mathcal{C}$ is chaotic
taking sections over an object of $\mathcal{C}$ is exact and hence
the lower row is exact. Since $\mathcal{O}(V) \to \mathcal{O}(U)$
is flat also the upper row is exact. Thus we conclude that the middle
arrow is an isomorphism by the $5$ lemma
(Homology, Lemma \ref{homology-lemma-five-lemma}).
\end{proof}






\section{Closed immersions of ringed topoi}
\label{section-closed-immersion}

\noindent
When do we declare a morphism of ringed topoi
$i : (\Sh(\mathcal{C}), \mathcal{O}) \to (\Sh(\mathcal{D}), \mathcal{O}')$
to be a closed immersion? By analogy with the discussion in
Modules, Section \ref{modules-section-closed-immersion}
it seems natural to assume at least:
\begin{enumerate}
\item The functor $i$ is a closed immersion of topoi
(Sites, Definition \ref{sites-definition-immersion-topoi}).
\item The associated map $\mathcal{O}' \to i_*\mathcal{O}$ is surjective.
\end{enumerate}
These conditions already imply a number of pleasing results which we discuss
in this section. However, it seems prudent to not actually define the
notion of a closed immersion of ringed topoi as there are many different
definitions we could use.

\begin{lemma}
\label{lemma-i-star-equivalence}
Let $i : (\Sh(\mathcal{C}), \mathcal{O}) \to (\Sh(\mathcal{D}), \mathcal{O}')$
be a morphism of ringed topoi. Assume $i$ is a closed immersion of topoi
and $i^\sharp : \mathcal{O}' \to i_*\mathcal{O}$ is surjective.
Denote $\mathcal{I} \subset \mathcal{O}'$ the kernel of $i^\sharp$.
The functor
$$
i_* :
\textit{Mod}(\mathcal{O})
\longrightarrow
\textit{Mod}(\mathcal{O}')
$$
is exact, fully faithful, with essential image those
$\mathcal{O}'$-modules $\mathcal{G}$ such that $\mathcal{I}\mathcal{G} = 0$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-exactness} and
Sites, Lemma \ref{sites-lemma-closed-immersion}
we see that $i_*$ is exact. From the fact that
$i_*$ is fully faithful on sheaves of sets, and the fact that
$i^\sharp$ is surjective it follows that $i_*$ is fully faithful
as a functor $\textit{Mod}(\mathcal{O}) \to \textit{Mod}(\mathcal{O}')$.
Namely, suppose that $\alpha : i_*\mathcal{F}_1 \to i_*\mathcal{F}_2$
is an $\mathcal{O}'$-module map. By the fully faithfulness of $i_*$
we obtain a map $\beta : \mathcal{F}_1 \to \mathcal{F}_2$ of sheaves
of sets. To prove $\beta$ is a map of modules we have to show
that
$$
\xymatrix{
\mathcal{O} \times \mathcal{F}_1 \ar[r] \ar[d] &
\mathcal{F}_1 \ar[d] \\
\mathcal{O} \times \mathcal{F}_2 \ar[r] &
\mathcal{F}_2
}
$$
commutes. It suffices to prove commutativity after applying $i_*$.
Consider
$$
\xymatrix{
\mathcal{O}' \times i_*\mathcal{F}_1 \ar[r] \ar[d] &
i_*\mathcal{O} \times i_*\mathcal{F}_1 \ar[r] \ar[d] &
i_*\mathcal{F}_1 \ar[d] \\
\mathcal{O}' \times i_*\mathcal{F}_2 \ar[r] &
i_*\mathcal{O} \times i_*\mathcal{F}_2 \ar[r] &
i_*\mathcal{F}_2
}
$$
We know the outer rectangle commutes. Since $i^\sharp$ is surjective
we conclude.

\medskip\noindent
To finish the proof we have to prove the statement on the essential
image of $i_*$. It is clear that $i_*\mathcal{F}$ is annihilated by
$\mathcal{I}$ for any $\mathcal{O}$-module $\mathcal{F}$. Conversely,
let $\mathcal{G}$ be a $\mathcal{O}'$-module with
$\mathcal{I}\mathcal{G} = 0$. By definition of a closed subtopos
there exists a subsheaf $\mathcal{U}$ of the final object of
$\mathcal{D}$ such that the essential image of $i_*$ on sheaves of sets
is the class of sheaves of sets $\mathcal{H}$ such that
$\mathcal{H} \times \mathcal{U} \to \mathcal{U}$ is an isomorphism.
In particular, $i_*\mathcal{O} \times \mathcal{U} = \mathcal{U}$.
This implies that
$\mathcal{I} \times \mathcal{U} = \mathcal{O} \times \mathcal{U}$.
Hence our module $\mathcal{G}$ satisfies
$\mathcal{G} \times \mathcal{U} = \{0\} \times \mathcal{U} = \mathcal{U}$
(because the zero module is isomorphic to the final object of sheaves
of sets). Thus there exists a sheaf of sets $\mathcal{F}$ on $\mathcal{C}$
with $i_*\mathcal{F} = \mathcal{G}$. Since $i_*$ is fully faithful on sheaves
of sets, we see that in order to define the
addition $\mathcal{F} \times \mathcal{F} \to \mathcal{F}$ and the
multiplication $\mathcal{O} \times \mathcal{F} \to \mathcal{F}$
it suffices to use the addition
$$
\mathcal{G} \times \mathcal{G} \longrightarrow \mathcal{G}
$$
(given to us as $\mathcal{G}$ is a $\mathcal{O}'$-module)
and the multiplication
$$
i_*\mathcal{O} \times \mathcal{G} \to \mathcal{G}
$$
which is given to us as we have the multiplication by
$\mathcal{O}'$ which annihilates $\mathcal{I}$ by assumption
and $i_*\mathcal{O} = \mathcal{O}'/\mathcal{I}$. By construction
$\mathcal{G}$ is isomorphic to the pushforward of the $\mathcal{O}$-module
$\mathcal{F}$ so constructed.
\end{proof}












\section{Tensor product}
\label{section-tensor-product}

\noindent
In Sections \ref{section-presheaves-modules} and
\ref{section-sheafification-presheaves-modules}
we defined the change of rings functor by a tensor
product construction. To be sure this construction makes sense also
to define the tensor product of presheaves of $\mathcal{O}$-modules.
To be precise, suppose $\mathcal{C}$ is a category,
$\mathcal{O}$ is a presheaf of rings, and $\mathcal{F}$, $\mathcal{G}$
are presheaves of $\mathcal{O}$-modules. In this case we define
$\mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G}$ to be the presheaf
$$
U
\longmapsto
(\mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G})(U)
=
\mathcal{F}(U) \otimes_{\mathcal{O}(U)} \mathcal{G}(U)
$$
If $\mathcal{C}$ is a site, $\mathcal{O}$ is a sheaf of rings and
$\mathcal{F}$, $\mathcal{G}$ are sheaves of $\mathcal{O}$-modules
then we define
$$
\mathcal{F} \otimes_\mathcal{O} \mathcal{G}
=
(\mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G})^\#
$$
to be the sheaf of $\mathcal{O}$-modules associated to the presheaf
$\mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G}$.

\medskip\noindent
Here are some formulas which we will use below without further mention:
$$
(\mathcal{F}
\otimes_{p, \mathcal{O}} \mathcal{G})
\otimes_{p, \mathcal{O}} \mathcal{H}
=
\mathcal{F}
\otimes_{p, \mathcal{O}} (\mathcal{G}
\otimes_{p, \mathcal{O}} \mathcal{H}),
$$
and similarly for sheaves.
If $\mathcal{O}_1 \to \mathcal{O}_2$ is a map of presheaves of rings,
then
$$
(\mathcal{F} \otimes_{p, \mathcal{O}_1} \mathcal{G})
\otimes_{p, \mathcal{O}_1} \mathcal{O}_2 =
(\mathcal{F} \otimes_{p, \mathcal{O}_1} \mathcal{O}_2)
\otimes_{p, \mathcal{O}_2}
(\mathcal{G} \otimes_{p, \mathcal{O}_1} \mathcal{O}_2),
$$
and similarly for sheaves.
These follow from their algebraic counterparts and sheafification.

\begin{lemma}
\label{lemma-sheafification-tensor}
Let $\mathcal{C}$ be a site. Let $\mathcal{O}$ be a presheaf of rings.
Let $\mathcal{F}$, $\mathcal{G}$ be presheaves of $\mathcal{O}$-modules.
Then
$\mathcal{F}^\# \otimes_{\mathcal{O}^\#} \mathcal{G}^\#$
is equal to
$(\mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G})^\#$.
\end{lemma}

\begin{proof}
Omitted. Hint: use the characterization of tensor product in terms
of bilinear maps below and use the universal property of sheafification.
\end{proof}

\noindent
Let $\mathcal{C}$ be a site, let $\mathcal{O}$ be a sheaf of rings and let
$\mathcal{F}$, $\mathcal{G}$, $\mathcal{H}$ be sheaves of
$\mathcal{O}$-modules. In this case we define
$$
\text{Bilin}_\mathcal{O}(\mathcal{F} \times \mathcal{G}, \mathcal{H})
=
\{\varphi \in
\Mor_{\Sh(\mathcal{C})}(
\mathcal{F} \times \mathcal{G}, \mathcal{H}) \mid
\varphi \text{ is }\mathcal{O}\text{-bilinear}\}.
$$
With this definition we have
$$
\Hom_\mathcal{O}
(\mathcal{F} \otimes_\mathcal{O} \mathcal{G}, \mathcal{H})
=
\text{Bilin}_\mathcal{O}(\mathcal{F} \times \mathcal{G}, \mathcal{H}).
$$
In other words $\mathcal{F} \otimes_\mathcal{O} \mathcal{G}$
represents the functor which associates to $\mathcal{H}$ the set
of bilinear maps $\mathcal{F} \times \mathcal{G} \to \mathcal{H}$.
In particular, since the notion of a bilinear map makes sense for
a pair of modules on a ringed topos, we see that the tensor
product of sheaves of modules is intrinsic to the topos (compare
the discussion in Section \ref{section-intrinsic}). In fact we
have the following.

\begin{lemma}
\label{lemma-tensor-product-pullback}
Let $f : (\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to (\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$ be
a morphism of ringed topoi. Let $\mathcal{F}$, $\mathcal{G}$
be $\mathcal{O}_\mathcal{D}$-modules. Then
$f^*(\mathcal{F} \otimes_{\mathcal{O}_\mathcal{D}} \mathcal{G})
= f^*\mathcal{F} \otimes_{\mathcal{O}_\mathcal{C}} f^*\mathcal{G}$
functorially in $\mathcal{F}$, $\mathcal{G}$.
\end{lemma}

\begin{proof}
For a sheaf $\mathcal{H}$ of $\mathcal{O}_\mathcal{C}$ modules we
have
\begin{align*}
\Hom_{\mathcal{O}_\mathcal{C}}(
f^*(\mathcal{F} \otimes_\mathcal{O} \mathcal{G}), \mathcal{H})
& =
\Hom_{\mathcal{O}_\mathcal{D}}(
\mathcal{F} \otimes_\mathcal{O} \mathcal{G}, f_*\mathcal{H}) \\
& =
\text{Bilin}_{\mathcal{O}_\mathcal{D}}(
\mathcal{F} \times \mathcal{G}, f_*\mathcal{H}) \\
& =
\text{Bilin}_{f^{-1}\mathcal{O}_\mathcal{D}}(
f^{-1}\mathcal{F} \times f^{-1}\mathcal{G}, \mathcal{H}) \\
& =
\Hom_{f^{-1}\mathcal{O}_\mathcal{D}}(
f^{-1}\mathcal{F} \otimes_{f^{-1}\mathcal{O}_\mathcal{D}} f^{-1}\mathcal{G},
\mathcal{H}) \\
& =
\Hom_{\mathcal{O}_\mathcal{C}}(
f^*\mathcal{F} \otimes_{f^*\mathcal{O}_\mathcal{D}} f^*\mathcal{G},
\mathcal{H})
\end{align*}
The interesting ``$=$'' in this sequence of equalities is the
third equality. It follows from the definition and adjointness of
$f_*$ and $f^{-1}$ (as discussed in previous sections) in a
straightforward manner.
\end{proof}

\begin{lemma}
\label{lemma-tensor-product-permanence}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\mathcal{F}$, $\mathcal{G}$ be sheaves of $\mathcal{O}$-modules.
\begin{enumerate}
\item If $\mathcal{F}$, $\mathcal{G}$ are locally free,
so is $\mathcal{F} \otimes_\mathcal{O} \mathcal{G}$.
\item If $\mathcal{F}$, $\mathcal{G}$ are finite locally free,
so is $\mathcal{F} \otimes_\mathcal{O} \mathcal{G}$.
\item If $\mathcal{F}$, $\mathcal{G}$ are locally generated
by sections, so is $\mathcal{F} \otimes_\mathcal{O} \mathcal{G}$.
\item If $\mathcal{F}$, $\mathcal{G}$ are of finite type,
so is $\mathcal{F} \otimes_\mathcal{O} \mathcal{G}$.
\item If $\mathcal{F}$, $\mathcal{G}$ are quasi-coherent,
so is $\mathcal{F} \otimes_\mathcal{O} \mathcal{G}$.
\item If $\mathcal{F}$, $\mathcal{G}$ are of finite presentation,
so is $\mathcal{F} \otimes_\mathcal{O} \mathcal{G}$.
\item If $\mathcal{F}$ is of finite presentation and $\mathcal{G}$ is coherent,
then $\mathcal{F} \otimes_\mathcal{O} \mathcal{G}$ is coherent.
\item If $\mathcal{F}$, $\mathcal{G}$ are coherent,
so is $\mathcal{F} \otimes_\mathcal{O} \mathcal{G}$.
\end{enumerate}
\end{lemma}

\begin{proof}
Omitted. Hint: Compare with
Sheaves of Modules, Lemma \ref{modules-lemma-tensor-product-permanence}.
\end{proof}



\section{Internal Hom}
\label{section-internal-hom}

\noindent
Let $\mathcal{C}$ be a category and let $\mathcal{O}$ be a presheaf
of rings. Let $\mathcal{F}$, $\mathcal{G}$ be presheaves of
$\mathcal{O}$-modules. Consider the rule
$$
U \longmapsto \Hom_{\mathcal{O}_U}(\mathcal{F}|_U, \mathcal{G}|_U).
$$
For $\varphi : V \to U$ in $\mathcal{C}$ we define a restriction mapping
$$
\Hom_{\mathcal{O}_U}(\mathcal{F}|_U, \mathcal{G}|_U)
\longrightarrow
\Hom_{\mathcal{O}_V}(\mathcal{F}|_V, \mathcal{G}|_V)
$$
by restricting via the relocalization morphism
$j : \mathcal{C}/V \to \mathcal{C}/U$, see
Sites, Lemma \ref{sites-lemma-relocalize}. Hence this defines a
presheaf $\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})$.
In addition, given an element
$\varphi \in \Hom_{\mathcal{O}|_U}(\mathcal{F}|_U, \mathcal{G}|_U)$
and a section $f \in \mathcal{O}(U)$ then we can define
$f\varphi \in \Hom_{\mathcal{O}|_U}(\mathcal{F}|_U, \mathcal{G}|_U)$
by either precomposing with multiplication by $f$ on $\mathcal{F}|_U$
or postcomposing with multiplication by $f$ on $\mathcal{G}|_U$ (it gives
the same result). Hence we in fact get a presheaf of $\mathcal{O}$-modules.
There is a canonical ``evaluation'' morphism
$$
\mathcal{F}
\otimes_{p, \mathcal{O}}
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})
\longrightarrow
\mathcal{G}.
$$

\begin{lemma}
\label{lemma-internal-hom}
If $\mathcal{C}$ is a site, $\mathcal{O}$ is a sheaf of rings,
$\mathcal{F}$ is a presheaf of $\mathcal{O}$-modules, and
$\mathcal{G}$ is a sheaf of $\mathcal{O}$-modules, then
$\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})$
is a sheaf of $\mathcal{O}$-modules.
\end{lemma}

\begin{proof}
Omitted. Hints: Note first that
$\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})
= \SheafHom_\mathcal{O}(\mathcal{F}^\#, \mathcal{G})$, which reduces
the question to the case where both $\mathcal{F}$ and $\mathcal{G}$
are sheaves. The result for sheaves of sets is
Sites, Lemma \ref{sites-lemma-glue-maps}.
\end{proof}

\begin{lemma}
\label{lemma-internal-hom-restriction}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\mathcal{F}, \mathcal{G}$ be sheaves of $\mathcal{O}$-modules.
Then formation of $\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})$
commutes with restriction to $U$ for $U \in \Ob(\mathcal{C})$.
\end{lemma}

\begin{proof}
Immediate from the definition.
\end{proof}

\begin{remark}
\label{remark-pullback-internal-hom}
Let $f : (\mathcal{C}, \mathcal{O}_\mathcal{C}) \to
(\mathcal{D}, \mathcal{O}_\mathcal{D})$ be a morphism
of ringed sites. Let
$\mathcal{F}, \mathcal{G}$ be sheaves of $\mathcal{O}_\mathcal{D}$-modules.
There is a canonical map
$$
f^*\SheafHom_{\mathcal{O}_\mathcal{D}}(\mathcal{F}, \mathcal{G})
\longrightarrow
\SheafHom_{\mathcal{O}_\mathcal{C}}(f^*\mathcal{F}, f^*\mathcal{G})
$$
Namely, this map is adjoint to the map
$$
\SheafHom_{\mathcal{O}_\mathcal{D}}(\mathcal{F}, \mathcal{G})
\longrightarrow
f_*\SheafHom_{\mathcal{O}_\mathcal{C}}(f^*\mathcal{F}, f^*\mathcal{G})
$$
defined as follows. Say $f$ is given by the continuous functor
$u : \mathcal{D} \to \mathcal{C}$. For sections over $V \in \Ob(\mathcal{D})$
we use the map
\begin{align*}
\Gamma(V, \SheafHom_{\mathcal{O}_\mathcal{D}}(\mathcal{F}, \mathcal{G}))
& =
\Hom_{\mathcal{O}_V}(\mathcal{F}|_V, \mathcal{G}|_V) \\
& \longrightarrow
\Hom_{\mathcal{O}_{u(V)}}(f^*\mathcal{F}|_{u(V)}, f^*\mathcal{G}|_{u(V)}) \\
& =
\Gamma(u(V), \SheafHom_{\mathcal{O}_\mathcal{C}}(f^*\mathcal{F},
f^*\mathcal{G})) \\
& =
\Gamma(V, f_*\SheafHom_{\mathcal{O}_\mathcal{C}}(f^*\mathcal{F},
f^*\mathcal{G}))
\end{align*}
where for the arrow we use pullback by the morphism
$(\mathcal{C}/u(V), \mathcal{O}_{u(V)}) \to
(\mathcal{D}/V, \mathcal{O}_V)$ induced by $f$.
\end{remark}

\noindent
In the situation of Lemma \ref{lemma-internal-hom}
the ``evaluation'' morphism
factors through the tensor product of sheaves of modules
$$
\mathcal{F}
\otimes_\mathcal{O}
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})
\longrightarrow
\mathcal{G}.
$$

\begin{lemma}
\label{lemma-internal-hom-commute-limits}
Internal hom and (co)limits.
Let $\mathcal{C}$ be a category and let $\mathcal{O}$ be a presheaf of rings.
\begin{enumerate}
\item For any presheaf of $\mathcal{O}$-modules $\mathcal{F}$ the functor
$$
\textit{PMod}(\mathcal{O}) \longrightarrow \textit{PMod}(\mathcal{O})
, \quad
\mathcal{G} \longmapsto \SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})
$$
commutes with arbitrary limits.
\item For any presheaf of $\mathcal{O}$-modules $\mathcal{G}$ the functor
$$
\textit{PMod}(\mathcal{O}) \longrightarrow \textit{PMod}(\mathcal{O})^{opp}
, \quad
\mathcal{F} \longmapsto \SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})
$$
commutes with arbitrary colimits, in a formula
$$
\SheafHom_\mathcal{O}(\colim_i \mathcal{F}_i, \mathcal{G})
=
\lim_i \SheafHom_\mathcal{O}(\mathcal{F}_i, \mathcal{G}).
$$
\end{enumerate}
Suppose that $\mathcal{C}$ is a site, and $\mathcal{O}$ is a sheaf of rings.
\begin{enumerate}
\item[(3)] For any sheaf of $\mathcal{O}$-modules $\mathcal{F}$ the functor
$$
\textit{Mod}(\mathcal{O}) \longrightarrow \textit{Mod}(\mathcal{O})
, \quad
\mathcal{G} \longmapsto \SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})
$$
commutes with arbitrary limits.
\item[(4)] For any sheaf of $\mathcal{O}$-modules $\mathcal{G}$ the functor
$$
\textit{Mod}(\mathcal{O}) \longrightarrow \textit{Mod}(\mathcal{O})^{opp}
, \quad
\mathcal{F} \longmapsto \SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})
$$
commutes with arbitrary colimits, in a formula
$$
\SheafHom_\mathcal{O}(\colim_i \mathcal{F}_i, \mathcal{G})
=
\lim_i \SheafHom_\mathcal{O}(\mathcal{F}_i, \mathcal{G}).
$$
\end{enumerate}
\end{lemma}

\begin{proof}
Let $\mathcal{I} \to \textit{PMod}(\mathcal{O})$, $i \mapsto \mathcal{G}_i$
be a diagram. Let $U$ be an object of the category $\mathcal{C}$.
As $j_U^*$ is both a left and a right adjoint we see that
$\lim_i j_U^*\mathcal{G}_i = j_U^* \lim_i \mathcal{G}_i$.
Hence we have
\begin{align*}
\SheafHom_\mathcal{O}(\mathcal{F}, \lim_i \mathcal{G}_i)(U)
& =
\Hom_{\mathcal{O}_U}(\mathcal{F}|_U, \lim_i \mathcal{G}_i|_U) \\
& =
\lim_i \Hom_{\mathcal{O}_U}(\mathcal{F}|_U, \mathcal{G}_i|_U) \\
& = \lim_i \SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}_i)(U)
\end{align*}
by definition of a limit. This proves (1). Part (2) is proved in exactly the
same way. Part (3) follows from (1) because the limit of a diagram of sheaves
is the same as the limit in the category of presheaves.
Finally, (4) follow because, in the formula we have
$$
\Mor_{\textit{Mod}(\mathcal{O})}(
\colim_i \mathcal{F}_i, \mathcal{G})
=
\Mor_{\textit{PMod}(\mathcal{O})}(
\colim^{PSh}_i \mathcal{F}_i, \mathcal{G})
$$
as the colimit $\colim_i \mathcal{F}_i$ is the sheafification of
the colimit $\colim^{PSh}_i \mathcal{F}_i$ in
$\textit{PMod}(\mathcal{O})$. Hence (4) follows from (2)
(by the remark on limits above again).
\end{proof}

\begin{lemma}
\label{lemma-internal-hom-exact}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\mathcal{F}$, $\mathcal{G}$ be $\mathcal{O}$-modules.
\begin{enumerate}
\item If $\mathcal{F}_2 \to \mathcal{F}_1 \to \mathcal{F} \to 0$
is an exact sequence of $\mathcal{O}$-modules, then
$$
0 \to
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}) \to
\SheafHom_\mathcal{O}(\mathcal{F}_1, \mathcal{G}) \to
\SheafHom_\mathcal{O}(\mathcal{F}_2, \mathcal{G})
$$
is exact.
\item If $0 \to \mathcal{G} \to \mathcal{G}_1 \to \mathcal{G}_2$
is an exact sequence of $\mathcal{O}$-modules, then
$$
0 \to
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}) \to
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}_1) \to
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}_2)
$$
is exact.
\end{enumerate}
\end{lemma}

\begin{proof}
Follows from Lemma \ref{lemma-internal-hom-commute-limits} and
Homology, Lemma \ref{homology-lemma-exact-functor}.
\end{proof}

\begin{lemma}
\label{lemma-internal-hom-adjoint-tensor}
Let $\mathcal{C}$ be a category. Let $\mathcal{O}$ be a presheaf of
rings.
\begin{enumerate}
\item Let $\mathcal{F}$, $\mathcal{G}$, $\mathcal{H}$ be
presheaves of $\mathcal{O}$-modules. There is a canonical isomorphism
$$
\SheafHom_\mathcal{O}
(\mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G}, \mathcal{H})
\longrightarrow
\SheafHom_\mathcal{O}
(\mathcal{F}, \SheafHom_\mathcal{O}(\mathcal{G}, \mathcal{H}))
$$
which is functorial in all three entries (sheaf Hom in
all three spots). In particular,
$$
\Mor_{\textit{PMod}(\mathcal{O})}(
\mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G}, \mathcal{H})
=
\Mor_{\textit{PMod}(\mathcal{O})}(
\mathcal{F}, \SheafHom_\mathcal{O}(\mathcal{G}, \mathcal{H}))
$$
\item
Suppose that $\mathcal{C}$ is a site, $\mathcal{O}$ is a sheaf of rings,
and $\mathcal{F}$, $\mathcal{G}$, $\mathcal{H}$ are sheaves of
$\mathcal{O}$-modules. There is a canonical isomorphism
$$
\SheafHom_\mathcal{O}
(\mathcal{F} \otimes_\mathcal{O} \mathcal{G}, \mathcal{H})
\longrightarrow
\SheafHom_\mathcal{O}
(\mathcal{F}, \SheafHom_\mathcal{O}(\mathcal{G}, \mathcal{H}))
$$
which is functorial in all three entries (sheaf Hom in
all three spots). In particular,
$$
\Mor_{\textit{Mod}(\mathcal{O})}(
\mathcal{F} \otimes_\mathcal{O} \mathcal{G}, \mathcal{H})
=
\Mor_{\textit{Mod}(\mathcal{O})}(
\mathcal{F}, \SheafHom_\mathcal{O}(\mathcal{G}, \mathcal{H}))
$$
\end{enumerate}
\end{lemma}

\begin{proof}
This is the analogue of
Algebra, Lemma \ref{algebra-lemma-hom-from-tensor-product}.
The proof is the same, and is omitted.
\end{proof}

\begin{lemma}
\label{lemma-tensor-commute-colimits}
Tensor product and colimits.
Let $\mathcal{C}$ be a category and let $\mathcal{O}$ be a presheaf of rings.
\begin{enumerate}
\item For any presheaf of $\mathcal{O}$-modules $\mathcal{F}$ the functor
$$
\textit{PMod}(\mathcal{O}) \longrightarrow \textit{PMod}(\mathcal{O})
, \quad
\mathcal{G} \longmapsto \mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G}
$$
commutes with arbitrary colimits.
\item
Suppose that $\mathcal{C}$ is a site, and $\mathcal{O}$ is a sheaf of rings.
For any sheaf of $\mathcal{O}$-modules $\mathcal{F}$ the functor
$$
\textit{Mod}(\mathcal{O}) \longrightarrow \textit{Mod}(\mathcal{O})
, \quad
\mathcal{G} \longmapsto \mathcal{F} \otimes_\mathcal{O} \mathcal{G}
$$
commutes with arbitrary colimits.
\end{enumerate}
\end{lemma}

\begin{proof}
This is because tensor product is adjoint to internal hom according
to Lemma \ref{lemma-internal-hom-adjoint-tensor}.
See Categories, Lemma \ref{categories-lemma-adjoint-exact}.
\end{proof}

\begin{lemma}
\label{lemma-adjoint-hom-restrict}
Let $\mathcal{C}$ be a category, resp.\ a site
Let $\mathcal{O} \to \mathcal{O}'$ be a map of presheaves, resp.\ sheaves
of rings. Then
$$
\Hom_\mathcal{O}(\mathcal{G}, \mathcal{F}) =
\Hom_{\mathcal{O}'}(\mathcal{G},
\SheafHom_\mathcal{O}(\mathcal{O}', \mathcal{F}))
$$
for any $\mathcal{O}'$-module $\mathcal{G}$ and $\mathcal{O}$-module
$\mathcal{F}$.
\end{lemma}

\begin{proof}
This is the analogue of
Algebra, Lemma \ref{algebra-lemma-adjoint-hom-restrict}.
The proof is the same, and is omitted.
\end{proof}

\begin{lemma}
\label{lemma-j-shriek-and-tensor}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $U \in \Ob(\mathcal{C})$.
For $\mathcal{G}$ in $\textit{Mod}(\mathcal{O}_U)$
and $\mathcal{F}$ in $\textit{Mod}(\mathcal{O})$
we have $j_{U!}\mathcal{G} \otimes_\mathcal{O} \mathcal{F} =
j_{U!}(\mathcal{G} \otimes_{\mathcal{O}_U} \mathcal{F}|_U)$.
\end{lemma}

\begin{proof}
Let $\mathcal{H}$ be an object of $\textit{Mod}(\mathcal{O})$.
Then
\begin{align*}
\Hom_\mathcal{O}(j_{U!}(\mathcal{G} \otimes_{\mathcal{O}_U} \mathcal{F}|_U),
\mathcal{H})
& =
\Hom_{\mathcal{O}_U}(\mathcal{G} \otimes_{\mathcal{O}_U} \mathcal{F}|_U,
\mathcal{H}|_U) \\
& =
\Hom_{\mathcal{O}_U}(\mathcal{G},
\SheafHom_{\mathcal{O}_U}(\mathcal{F}|_U, \mathcal{H}|_U)) \\
& =
\Hom_{\mathcal{O}_U}(\mathcal{G},
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{H})|_U) \\
& =
\Hom_\mathcal{O}(j_{U!}\mathcal{G},
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{H})) \\
& =
\Hom_\mathcal{O}(j_{U!}\mathcal{G} \otimes_\mathcal{O} \mathcal{F},
\mathcal{H})
\end{align*}
The first equality because $j_{U!}$ is a left adjoint to restriction
of modules.
The second by Lemma \ref{lemma-internal-hom-adjoint-tensor}.
The third by Lemma \ref{lemma-internal-hom-restriction}.
The fourth because $j_{U!}$ is a left adjoint to restriction
of modules.
The fifth by Lemma \ref{lemma-internal-hom-adjoint-tensor}.
The lemma follows from this and the Yoneda lemma.
\end{proof}

\begin{remark}
\label{remark-j-shriek-tensor}
Let $\mathcal{C}$ be a site. Let $\mathcal{F}$ be a sheaf of
sets on $\mathcal{C}$ and consider the localization morphism
$j : \Sh(\mathcal{C})/\mathcal{F} \to \Sh(\mathcal{C})$.
See Sites, Definition \ref{sites-definition-localize-topos}.
We claim that (a) $j_!\mathbf{Z} = \mathbf{Z}_\mathcal{F}^\#$
and (b) $j_!(j^{-1}\mathcal{H}) = j_!\mathbf{Z} \otimes_\mathbf{Z} \mathcal{H}$
for any abelian sheaf $\mathcal{H}$ on $\mathcal{C}$.
Let $\mathcal{G}$ be an abelian on $\mathcal{C}$.
Part (a) follows from the Yoneda lemma because
$$
\Hom(j_!\mathbf{Z}, \mathcal{G}) =
\Hom(\mathbf{Z}, j^{-1}\mathcal{G}) =
\Hom(\mathbf{Z}_\mathcal{F}^\#, \mathcal{G})
$$
where the second equality holds because both sides of
the equality evaluate to the set of maps from $\mathcal{F} \to \mathcal{G}$
viewed as an abelian group. For (b) we use the Yoneda lemma and
\begin{align*}
\Hom(j_!(j^{-1}\mathcal{H}), \mathcal{G})
& =
\Hom(j^{-1}\mathcal{H}, j^{-1}\mathcal{G}) \\
& =
\Hom(\mathbf{Z}, \SheafHom(j^{-1}\mathcal{H}, j^{-1}\mathcal{G})) \\
& =
\Hom(\mathbf{Z}, j^{-1}\SheafHom(\mathcal{H}, \mathcal{G})) \\
& =
\Hom(j_!\mathbf{Z}, \SheafHom(\mathcal{H}, \mathcal{G})) \\
& =
\Hom(j_!\mathbf{Z} \otimes_\mathbf{Z} \mathcal{H}, \mathcal{G})
\end{align*}
Here we use adjunction, the fact that taking $\SheafHom$ commutes
with localization, and Lemma \ref{lemma-internal-hom-adjoint-tensor}.
\end{remark}

\begin{lemma}
\label{lemma-hom-finite-presentation-colimit}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\mathcal{F}$ be an $\mathcal{O}$-module of finite presentation. Let
$\mathcal{G} = \colim_{\lambda \in \Lambda} \mathcal{G}_\lambda$
be a filtered colimit of $\mathcal{O}$-modules. Then the canonical map
$$
\colim_\lambda \SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}_\lambda)
\longrightarrow
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G})
$$
is an isomorphism.
\end{lemma}

\begin{proof}
It suffices to show the arrow is an isomorphism after restriction to $U$
for all $U$ in $\mathcal{C}$. Both taking colimits of sheaves of
modules and taking internal hom commute with restriction to $U$.
See for example Lemmas \ref{lemma-exactness-pushforward-pullback} and
\ref{lemma-internal-hom-restriction}. Fix $U$. Given a covering
$\{U_i \to U\}_{i \in I}$, then it suffices to prove the restriction
to each $U_i$ is an isomorphism. Hence we may assume
$\mathcal{F}$ has a global presentation
$$
\bigoplus\nolimits_{j = 1, \ldots, m}
\mathcal{O}
\longrightarrow
\bigoplus\nolimits_{i = 1, \ldots, n}
\mathcal{O}
\to
\mathcal{F}
\to
0
$$
The functor $\SheafHom_\mathcal{O}(-, -)$ commutes with finite direct sums
in either variable and $\SheafHom_\mathcal{O}(\mathcal{O}, -)$
is the identity functor. By this and by Lemma \ref{lemma-internal-hom-exact}
we obtain an exact sequence
$$
0 \to
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}) \to
\bigoplus\nolimits_{i = 1, \ldots, n} \mathcal{G} \to
\bigoplus\nolimits_{j = 1, \ldots, m} \mathcal{G}
$$
Since filtered colimits are exact in $\textit{Mod}(\mathcal{O})$
by Lemma \ref{lemma-limits-colimits}
also the top row in the following commutative diagram is exact
$$
\xymatrix{
0 \ar[r] &
\colim_\lambda \SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}_\lambda)
\ar[r] \ar[d] &
\colim_\lambda \bigoplus\nolimits_{i = 1, \ldots, n} \mathcal{G}_\lambda
\ar[r] \ar[d] &
\colim_\lambda \bigoplus\nolimits_{j = 1, \ldots, m} \mathcal{G}_\lambda
\ar[d] \\
0 \ar[r] &
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}) \ar[r] &
\bigoplus\nolimits_{i = 1, \ldots, n} \mathcal{G} \ar[r] &
\bigoplus\nolimits_{j = 1, \ldots, m} \mathcal{G}
}
$$
Since the right two vertical arrows are isomorphisms we conclude.
\end{proof}

\begin{lemma}
\label{lemma-finite-presentation-quasi-compact-colimit}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\mathcal{G} = \colim_{\lambda \in \Lambda} \mathcal{G}_\lambda$
be a filtered colimit of $\mathcal{O}$-modules.
Let $\mathcal{F}$ be an $\mathcal{O}$-module of finite presentation.
Then we have
$$
\colim_\lambda \Hom_\mathcal{O}(\mathcal{F}, \mathcal{G}_\lambda)
=
\Hom_\mathcal{O}(\mathcal{F}, \mathcal{G}).
$$
if the hypotheses of
Sites, Lemma \ref{sites-lemma-directed-colimits-global-sections} part (4)
are satisfied for the site $\mathcal{C}$; please see
Sites, Remark \ref{sites-remark-stronger-conditions}.
\end{lemma}

\begin{proof}
Set $\mathcal{H} =
\SheafHom_\mathcal{O}(\mathcal{F}, \colim \mathcal{G}_\lambda)$
and $\mathcal{H}_\lambda =
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{G}_\lambda)$.
Recall that
$$
\Hom_\mathcal{O}(\mathcal{F}, \mathcal{G}) = \Gamma(\mathcal{C}, \mathcal{H})
\quad\text{and}\quad
\Hom_\mathcal{O}(\mathcal{F}, \mathcal{G}_\lambda) =
\Gamma(\mathcal{C}, \mathcal{H}_\lambda)
$$
by construction. By Lemma \ref{lemma-hom-finite-presentation-colimit} we have
$\mathcal{H} = \colim \mathcal{H}_\lambda$. Thus the lemma follows from
Sites, Lemma \ref{sites-lemma-directed-colimits-global-sections}.
\end{proof}









\section{Flat modules}
\label{section-flat}

\noindent
We can define flat modules exactly as in the case of modules over rings.

\begin{definition}
\label{definition-flat}
Let $\mathcal{C}$ be a category.
Let $\mathcal{O}$ be a presheaf of rings.
\begin{enumerate}
\item A presheaf $\mathcal{F}$ of $\mathcal{O}$-modules is called
{\it flat} if the functor
$$
\textit{PMod}(\mathcal{O})
\longrightarrow
\textit{PMod}(\mathcal{O}), \quad
\mathcal{G} \mapsto \mathcal{G} \otimes_{p, \mathcal{O}} \mathcal{F}
$$
is exact.
\item A map $\mathcal{O} \to \mathcal{O}'$ of presheaves of rings
is called {\it flat} if $\mathcal{O}'$ is flat as a presheaf of
$\mathcal{O}$-modules.
\item If $\mathcal{C}$ is a site, $\mathcal{O}$ is a sheaf of rings
and $\mathcal{F}$ is a sheaf of $\mathcal{O}$-modules, then we
say $\mathcal{F}$ is {\it flat} if the functor
$$
\textit{Mod}(\mathcal{O})
\longrightarrow
\textit{Mod}(\mathcal{O}), \quad
\mathcal{G} \mapsto \mathcal{G} \otimes_\mathcal{O} \mathcal{F}
$$
is exact.
\item A map $\mathcal{O} \to \mathcal{O}'$ of sheaves of rings on a site
is called {\it flat} if $\mathcal{O}'$ is flat as a sheaf of
$\mathcal{O}$-modules.
\end{enumerate}
\end{definition}

\noindent
The notion of a flat module or flat ring map is intrinsic
(Section \ref{section-intrinsic}).

\begin{lemma}
\label{lemma-flatness-presheaves}
Let $\mathcal{C}$ be a category.
Let $\mathcal{O}$ be a presheaf of rings.
Let $\mathcal{F}$ be a presheaf of $\mathcal{O}$-modules.
If each $\mathcal{F}(U)$ is a flat $\mathcal{O}(U)$-module,
then $\mathcal{F}$ is flat.
\end{lemma}

\begin{proof}
This is immediate from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-flatness-sheafification}
Let $\mathcal{C}$ be a site.
Let $\mathcal{O}$ be a presheaf of rings.
Let $\mathcal{F}$ be a presheaf of $\mathcal{O}$-modules.
If $\mathcal{F}$ is a flat $\mathcal{O}$-module, then
$\mathcal{F}^\#$ is a flat $\mathcal{O}^\#$-module.
\end{lemma}

\begin{proof}
Omitted. (Hint: Sheafification is exact.)
\end{proof}

\begin{lemma}
\label{lemma-flatness-sheafification-refined}
Let $\mathcal{C}$ be a site. Let $\mathcal{O}$ be a presheaf of rings.
Let $\mathcal{F}$ be a presheaf of $\mathcal{O}$-modules. Assume
that every object $U$ of $\mathcal{C}$ has a covering $\{U_i \to U\}_{i \in I}$
such that $\mathcal{F}(U_i)$ is a flat $\mathcal{O}(U_i)$-module.
Then $\mathcal{F}^\#$ is a flat $\mathcal{O}^\#$-module.
\end{lemma}

\begin{proof}
Let $\mathcal{G} \subset \mathcal{G}'$ be an inclusion of
$\mathcal{O}^\#$-modules. We have to show that
$$
\mathcal{G} \otimes_{\mathcal{O}^\#} \mathcal{F}^\#
\longrightarrow
\mathcal{G}' \otimes_{\mathcal{O}^\#} \mathcal{F}^\#
$$
is injective. By Lemma \ref{lemma-sheafification-tensor}
the source of this arrow is the sheafification of
the presheaf $\mathcal{G} \otimes_{p, \mathcal{O}} \mathcal{F}$
and similarly for the target. If $U$ is an object of $\mathcal{C}$ such that
$\mathcal{F}(U)$ is a flat $\mathcal{O}(U)$-module, then
$$
(\mathcal{G} \otimes_{p, \mathcal{O}} \mathcal{F})(U) =
\mathcal{G}(U) \otimes_{\mathcal{O}(U)} \mathcal{F}(U)
\longrightarrow
\mathcal{G}'(U) \otimes_{\mathcal{O}(U)} \mathcal{F}(U) =
(\mathcal{G}' \otimes_{p, \mathcal{O}} \mathcal{F})(U)
$$
is injective. Hence we reduce to showing: given a map of presheaves
$f : \mathcal{H} \to \mathcal{H}'$ on $\mathcal{C}$ such that
every $U$ in $\mathcal{C}$ has a covering $\{U_i \to U\}_{i \in I}$
with $\mathcal{H}(U_i) \to \mathcal{H}'(U_i)$ injective, then
$f^\#$ is injective. This we leave to the reader as an exercise.
\end{proof}

\begin{lemma}
\label{lemma-colimits-flat}
Colimits and tensor product.
\begin{enumerate}
\item A filtered colimit of flat presheaves of modules
is flat. A direct sum of flat presheaves of modules is flat.
\item A filtered colimit of flat sheaves of modules is flat.
A direct sum of flat sheaves of modules is flat.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) follows from Lemma \ref{lemma-tensor-commute-colimits} and
Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}
by looking at sections over objects.
To see part (2), use Lemma \ref{lemma-tensor-commute-colimits} and
the fact that a filtered colimit of exact
complexes is an exact complex (this uses that sheafification is exact
and commutes with colimits). Some details omitted.
\end{proof}

\begin{lemma}
\label{lemma-restriction-flat}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $U$ be an object of $\mathcal{C}$.
If $\mathcal{F}$ is a flat $\mathcal{O}$-module, then
$\mathcal{F}|_U$ is a flat $\mathcal{O}_U$-module.
\end{lemma}

\begin{proof}
Let $\mathcal{G}_1 \to \mathcal{G}_2 \to \mathcal{G}_3$ be
an exact complex of $\mathcal{O}_U$-modules.
Since $j_{U!}$ is exact (Lemma \ref{lemma-extension-by-zero-exact})
and $\mathcal{F}$ is flat as an $\mathcal{O}$-modules
then we see that the complex made up of the modules
$$
j_{U!}(\mathcal{G}_i \otimes_{\mathcal{O}_U} \mathcal{F}|_U) =
j_{U!}\mathcal{G}_i \otimes_\mathcal{O} \mathcal{F}
$$
(Lemma \ref{lemma-j-shriek-and-tensor}) is exact. We conclude that
$\mathcal{G}_1 \otimes_{\mathcal{O}_U} \mathcal{F}|_U \to
\mathcal{G}_2 \otimes_{\mathcal{O}_U} \mathcal{F}|_U \to
\mathcal{G}_3 \otimes_{\mathcal{O}_U} \mathcal{F}|_U$
is exact by
Lemma \ref{lemma-j-shriek-reflects-exactness}.
\end{proof}

\begin{lemma}
\label{lemma-j-shriek-flat}
Let $\mathcal{C}$ be a category.
Let $\mathcal{O}$ be a presheaf of rings.
Let $U$ be an object of $\mathcal{C}$.
Consider the functor $j_U : \mathcal{C}/U \to \mathcal{C}$.
\begin{enumerate}
\item The presheaf of $\mathcal{O}$-modules
$j_{U!}\mathcal{O}_U$ (see
Remark \ref{remark-localize-presheaves})
is flat.
\item If $\mathcal{C}$ is a site, $\mathcal{O}$ is a sheaf of rings,
$j_{U!}\mathcal{O}_U$ is a flat sheaf of $\mathcal{O}$-modules.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). By the discussion in
Remark \ref{remark-localize-presheaves}
we see that
$$
j_{U!}\mathcal{O}_U(V)
=
\bigoplus\nolimits_{\varphi \in \Mor_\mathcal{C}(V, U)}
\mathcal{O}(V)
$$
which is a flat $\mathcal{O}(V)$-module. Hence (1) follows from
Lemma \ref{lemma-flatness-presheaves}.
Then (2) follows as $j_{U!}\mathcal{O}_U = (j_{U!}\mathcal{O}_U)^\#$
(the first $j_{U!}$ on sheaves, the second on presheaves)
and Lemma \ref{lemma-flatness-sheafification}.
\end{proof}

\begin{lemma}
\label{lemma-module-quotient-flat}
Let $\mathcal{C}$ be a category.
Let $\mathcal{O}$ be a presheaf of rings.
\begin{enumerate}
\item Any presheaf of $\mathcal{O}$-modules is a quotient of
a direct sum $\bigoplus j_{U_i!}\mathcal{O}_{U_i}$.
\item Any presheaf of $\mathcal{O}$-modules is a quotient of
a flat presheaf of $\mathcal{O}$-modules.
\item If $\mathcal{C}$ is a site, $\mathcal{O}$ is a sheaf of rings,
then any sheaf of $\mathcal{O}$-modules is a quotient of
a direct sum $\bigoplus j_{U_i!}\mathcal{O}_{U_i}$.
\item If $\mathcal{C}$ is a site, $\mathcal{O}$ is a sheaf of rings,
then any sheaf of $\mathcal{O}$-modules is a quotient of
a flat sheaf of $\mathcal{O}$-modules.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). For every object $U$ of $\mathcal{C}$ and every
$s \in \mathcal{F}(U)$ we get a morphism
$j_{U!}\mathcal{O}_U \to \mathcal{F}$, namely the adjoint to
the morphism $\mathcal{O}_U \to \mathcal{F}|_U$, $1 \mapsto s$.
Clearly the map
$$
\bigoplus\nolimits_{(U, s)} j_{U!}\mathcal{O}_U
\longrightarrow
\mathcal{F}
$$
is surjective. The source is flat by combining Lemmas
\ref{lemma-colimits-flat} and \ref{lemma-j-shriek-flat}
which proves (2). The sheaf case follows from this either by
sheafifying or repeating the same argument.
\end{proof}

\begin{lemma}
\label{lemma-flat-tor-zero}
Let $\mathcal{C}$ be a category.
Let $\mathcal{O}$ be a presheaf of rings.
Let
$$
0 \to \mathcal{F}'' \to \mathcal{F}' \to \mathcal{F} \to 0
$$
be a short exact sequence of presheaves of $\mathcal{O}$-modules.
Let $\mathcal{G}$ be a presheaf of $\mathcal{O}$-modules.
\begin{enumerate}
\item If $\mathcal{F}$ is a flat presheaf of modules, then
the sequence
$$
0 \to
\mathcal{F}'' \otimes_{p, \mathcal{O}} \mathcal{G} \to
\mathcal{F}' \otimes_{p, \mathcal{O}} \mathcal{G} \to
\mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G} \to 0
$$
is exact.
\item If $\mathcal{C}$ is a site, $\mathcal{O}$,
$\mathcal{F}$, $\mathcal{F}'$, $\mathcal{F}''$, and
$\mathcal{G}$ are sheaves, and $\mathcal{F}$ is flat
as a sheaf of modules, then the sequence
$$
0 \to
\mathcal{F}'' \otimes_\mathcal{O} \mathcal{G} \to
\mathcal{F}' \otimes_\mathcal{O} \mathcal{G} \to
\mathcal{F} \otimes_\mathcal{O} \mathcal{G} \to 0
$$
is exact.
\end{enumerate}
\end{lemma}

\begin{proof}
Choose a flat presheaf of $\mathcal{O}$-modules $\mathcal{G}'$
which surjects onto $\mathcal{G}$. This is possible by
Lemma \ref{lemma-module-quotient-flat}. Let
$\mathcal{G}'' = \Ker(\mathcal{G}' \to \mathcal{G})$.
The lemma follows by applying the snake lemma to the following
diagram
$$
\begin{matrix}
 & & 0 & & 0 & & 0 & & \\
 & & \uparrow & & \uparrow & & \uparrow & & \\
 & & \mathcal{F}'' \otimes_{p, \mathcal{O}} \mathcal{G} & \to &
     \mathcal{F}' \otimes_{p, \mathcal{O}} \mathcal{G} & \to &
     \mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G} & \to & 0 \\
 & & \uparrow & & \uparrow & & \uparrow & & \\
0 & \to & \mathcal{F}'' \otimes_{p, \mathcal{O}} \mathcal{G}' & \to &
          \mathcal{F}' \otimes_{p, \mathcal{O}} \mathcal{G}' & \to &
          \mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G}' & \to & 0 \\
 & & \uparrow & & \uparrow & & \uparrow & & \\
 & & \mathcal{F}'' \otimes_{p, \mathcal{O}} \mathcal{G}'' & \to &
     \mathcal{F}' \otimes_{p, \mathcal{O}} \mathcal{G}'' & \to &
     \mathcal{F} \otimes_{p, \mathcal{O}} \mathcal{G}'' & \to & 0 \\
 & & & & & & \uparrow & & \\
 & & & & & & 0 & &
\end{matrix}
$$
with exact rows and columns. The middle row is exact because tensoring
with the flat module $\mathcal{G}'$ is exact. The proof in the case
of sheaves is exactly the same.
\end{proof}

\begin{lemma}
\label{lemma-flat-ses}
Let $\mathcal{C}$ be a category.
Let $\mathcal{O}$ be a presheaf of rings.
Let
$$
0 \to
\mathcal{F}_2 \to
\mathcal{F}_1 \to
\mathcal{F}_0 \to 0
$$
be a short exact sequence of presheaves of $\mathcal{O}$-modules.
\begin{enumerate}
\item If $\mathcal{F}_2$ and $\mathcal{F}_0$ are flat so is
$\mathcal{F}_1$.
\item If $\mathcal{F}_1$ and $\mathcal{F}_0$ are flat so is
$\mathcal{F}_2$.
\end{enumerate}
If $\mathcal{C}$ is a site and $\mathcal{O}$ is a
sheaf of rings then the same result holds in $\textit{Mod}(\mathcal{O})$.
\end{lemma}

\begin{proof}
Let $\mathcal{G}^\bullet$ be an arbitrary exact complex of presheaves
of $\mathcal{O}$-modules. Assume that $\mathcal{F}_0$ is flat.
By Lemma \ref{lemma-flat-tor-zero} we see that
$$
0 \to
\mathcal{G}^\bullet \otimes_{p, \mathcal{O}} \mathcal{F}_2 \to
\mathcal{G}^\bullet \otimes_{p, \mathcal{O}} \mathcal{F}_1 \to
\mathcal{G}^\bullet \otimes_{p, \mathcal{O}} \mathcal{F}_0 \to 0
$$
is a short exact sequence of complexes of presheaves of
$\mathcal{O}$-modules. Hence (1) and (2) follow from the snake lemma.
The case of sheaves of modules is proved in the same way.
\end{proof}

\begin{lemma}
\label{lemma-flat-resolution-of-flat}
Let $\mathcal{C}$ be a category.
Let $\mathcal{O}$ be a presheaf of rings.
Let
$$
\ldots \to
\mathcal{F}_2 \to
\mathcal{F}_1 \to
\mathcal{F}_0 \to
\mathcal{Q} \to 0
$$
be an exact complex of presheaves of $\mathcal{O}$-modules.
If $\mathcal{Q}$ and all $\mathcal{F}_i$ are flat $\mathcal{O}$-modules,
then for any presheaf $\mathcal{G}$ of $\mathcal{O}$-modules the
complex
$$
\ldots \to
\mathcal{F}_2 \otimes_{p, \mathcal{O}} \mathcal{G} \to
\mathcal{F}_1 \otimes_{p, \mathcal{O}} \mathcal{G} \to
\mathcal{F}_0 \otimes_{p, \mathcal{O}} \mathcal{G} \to
\mathcal{Q} \otimes_{p, \mathcal{O}} \mathcal{G} \to 0
$$
is exact also. If $\mathcal{C}$ is a site and $\mathcal{O}$ is a
sheaf of rings then the same result holds $\textit{Mod}(\mathcal{O})$.
\end{lemma}

\begin{proof}
Follows from Lemma \ref{lemma-flat-tor-zero} by splitting the complex
into short exact sequences and using Lemma \ref{lemma-flat-ses} to
prove inductively that $\Im(\mathcal{F}_{i + 1} \to \mathcal{F}_i)$
is flat.
\end{proof}

\begin{lemma}
\label{lemma-tensor-flats}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. If $\mathcal{G}$ and
$\mathcal{F}$ are flat $\mathcal{O}$-modules, then
$\mathcal{G} \otimes_\mathcal{O} \mathcal{F}$ is a flat $\mathcal{O}$-module.
\end{lemma}

\begin{proof}
This is true because
$$
(\mathcal{G} \otimes_\mathcal{O} \mathcal{F}) \otimes_\mathcal{O} \mathcal{H}
=
\mathcal{G} \otimes_\mathcal{O} (\mathcal{F} \otimes_\mathcal{O} \mathcal{H})
$$
and a composition of exact functors is exact.
\end{proof}

\begin{lemma}
\label{lemma-flat-change-of-rings}
Let $\mathcal{O}_1 \to \mathcal{O}_2$ be a map of sheaves
of rings on a site $\mathcal{C}$. If $\mathcal{G}$ is a
flat $\mathcal{O}_1$-module, then
$\mathcal{G} \otimes_{\mathcal{O}_1} \mathcal{O}_2$
is a flat $\mathcal{O}_2$-module.
\end{lemma}

\begin{proof}
This is true because
$$
(\mathcal{G} \otimes_{\mathcal{O}_1} \mathcal{O}_2)
\otimes_{\mathcal{O}_2} \mathcal{H}
=
\mathcal{G} \otimes_{\mathcal{O}_1} \mathcal{F}
$$
(as sheaves of abelian groups for example).
\end{proof}

\noindent
The following lemma is the analogue of the equational criterion of
flatness (Algebra, Lemma \ref{algebra-lemma-flat-eq}).

\begin{lemma}
\label{lemma-flat-eq}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let $\mathcal{F}$ be an
$\mathcal{O}$-module. The following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is a flat $\mathcal{O}$-module.
\item Let $U$ be an object of $\mathcal{C}$ and let
$$
\mathcal{O}_U \xrightarrow{(f_1, \ldots, f_n)}
\mathcal{O}_U^{\oplus n} \xrightarrow{(s_1, \ldots, s_n)}
\mathcal{F}|_U
$$
be a complex of $\mathcal{O}_U$-modules. Then there exists a covering
$\{U_i \to U\}$ and for each $i$ a factorization
$$
\mathcal{O}_{U_i}^{\oplus n}
\xrightarrow{B_i}
\mathcal{O}_{U_i}^{\oplus l_i} \xrightarrow{(t_{i1}, \ldots, t_{il_i})}
\mathcal{F}|_{U_i}
$$
of $(s_1, \ldots, s_n)|_{U_i}$ such that
$B_i \circ (f_1, \ldots, f_n)|_{U_i} = 0$.
\item Let $U$ be an object of $\mathcal{C}$ and let
$$
\mathcal{O}_U^{\oplus m} \xrightarrow{A}
\mathcal{O}_U^{\oplus n} \xrightarrow{(s_1, \ldots, s_n)}
\mathcal{F}|_U
$$
be a complex of $\mathcal{O}_U$-modules. Then there exists a covering
$\{U_i \to U\}$ and for each $i$ a factorization
$$
\mathcal{O}_{U_i}^{\oplus n}
\xrightarrow{B_i}
\mathcal{O}_{U_i}^{\oplus l_i} \xrightarrow{(t_{i1}, \ldots, t_{il_i})}
\mathcal{F}|_{U_i}
$$
of $(s_1, \ldots, s_n)|_{U_i}$ such that
$B_i \circ A|_{U_i} = 0$.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1). Let $\mathcal{I} \subset \mathcal{O}_U$ be the sheaf of ideals
generated by $f_1, \ldots, f_n$. Then $\sum f_j \otimes s_j$ is
a section of $\mathcal{I} \otimes_{\mathcal{O}_U} \mathcal{F}|_U$
which maps to zero in $\mathcal{F}|_U$. As $\mathcal{F}|_U$ is flat
(Lemma \ref{lemma-restriction-flat}) the map
$\mathcal{I} \otimes_{\mathcal{O}_U} \mathcal{F}|_U \to \mathcal{F}|_U$
is injective. Since $\mathcal{I} \otimes_{\mathcal{O}_U} \mathcal{F}|_U$
is the sheaf associated to the presheaf tensor product, we see
there exists a covering $\{U_i \to U\}$ such
that $\sum f_j|_{U_i} \otimes s_j|_{U_i}$ is zero in
$\mathcal{I}(U_i) \otimes_{\mathcal{O}(U_i)} \mathcal{F}(U_i)$.
Unwinding the definitions using Algebra, Lemma \ref{algebra-lemma-relations}
we find $t_{i1}, \ldots, t_{i l_i} \in \mathcal{F}(U_i)$ and
$a_{ijk} \in \mathcal{O}(U_i)$
such that $\sum_j a_{ijk}f_j|_{U_i} = 0$ and
$s_j|_{U_i} = \sum_k a_{ijk}t_{ik}$.
Thus (2) holds.

\medskip\noindent
Assume (2). Let $U$, $n$, $m$, $A$ and $s_1, \ldots, s_n$ as in (3) be given.
Observe that $A$ has $m$ columns. We will prove the assertion of (3)
is true by induction on $m$. For the base case $m = 0$ we
can take the covering $\{U \to U\}$ and for the factorization we use
$\mathcal{O}_U^n \to \mathcal{O}_U^n \to \mathcal{F}|_U$ where
the first map is the identity and the second is $(s_1, \ldots, s_n)$.
Assume $m > 0$. Let $(f_1, \ldots, f_n)$ be the last column of $A$
and apply (2). This gives new diagrams
$$
\mathcal{O}_{U_i}^{\oplus m} \xrightarrow{B_i \circ A|_{U_i}}
\mathcal{O}_{U_i}^{\oplus l_i} \xrightarrow{(t_{i1}, \ldots, t_{il_i})}
\mathcal{F}|_{U_i}
$$
but the last column of $A_i = B_i \circ A|_{U_i}$ is zero.
Hence we can apply the induction hypothesis to
$U_i$, $l_i$, $m - 1$, the matrix consisting of
the first $m - 1$ columns of $A_i$, and $t_{i1}, \ldots, t_{il_i}$
to get coverings $\{U_{ij} \to U_j\}$ and factorizations
$$
\mathcal{O}_{U_{ij}}^{\oplus l_i}
\xrightarrow{C_{ij}}
\mathcal{O}_{U_{ij}}^{\oplus k_{ij}}
\xrightarrow{(v_{ij1}, \ldots, v_{ij k_{ij}})}
\mathcal{F}|_{U_{ij}}
$$
of $(t_{i1}, \ldots, t_{il_i})|_{U_{ij}}$ such that
$C_i \circ B_i|_{U_{ij}} \circ A|_{U_{ij}} = 0$.
Then $\{U_{ij} \to U\}$ is a covering and we get the
desired factorizations
using $B_{ij} = C_i \circ B_i|_{U_{ij}}$ and
$v_{ija}$. In this way we see that (2) implies (3).

\medskip\noindent
Assume (3). Let $\mathcal{G} \to \mathcal{H}$ be an injective homomorphism
of $\mathcal{O}$-modules. We have to show that
$\mathcal{G} \otimes_\mathcal{O} \mathcal{F} \to
\mathcal{H} \otimes_\mathcal{O} \mathcal{F}$
is injective. Let $U$ be an object of $\mathcal{C}$
and let $s \in (\mathcal{G} \otimes_\mathcal{O} \mathcal{F})(U)$
be a section which maps to zero in
$\mathcal{H} \otimes_\mathcal{O} \mathcal{F}$.
We have to show that $s$ is zero. Since
$\mathcal{G} \otimes_\mathcal{O} \mathcal{F}$
is a sheaf, it suffices to find a covering $\{U_i \to U\}_{i \in I}$
of $\mathcal{C}$ such that $s|_{U_i}$ is zero for all $i \in I$.
Hence we may always replace $U$ by the members of a covering.
In particular, since $\mathcal{G} \otimes_\mathcal{O} \mathcal{F}$
is the sheafification of $\mathcal{G} \otimes_{p, \mathcal{O}} \mathcal{F}$
we may assume that $s$ is the image of $s' \in 
\mathcal{G}(U) \otimes_{\mathcal{O}(U)} \mathcal{F}(U)$.
Arguing similarly for $\mathcal{H} \otimes_\mathcal{O} \mathcal{F}$
we may assume that $s'$ maps to zero in
$\mathcal{H}(U) \otimes_{\mathcal{O}(U)} \mathcal{F}(U)$.
Write $\mathcal{F}(U) = \colim M_\alpha$ as a filtered colimit of finitely
presented $\mathcal{O}(U)$-modules $M_\alpha$
(Algebra, Lemma \ref{algebra-lemma-module-colimit-fp}).
Since tensor product commutes with filtered colimits
(Algebra, Lemma \ref{algebra-lemma-tensor-products-commute-with-limits})
we can choose an $\alpha$ such that $s'$
comes from some $s'' \in \mathcal{G}(U) \otimes_{\mathcal{O}(U)} M_\alpha$
and such that $s''$ maps to zero in
$\mathcal{H}(U) \otimes_{\mathcal{O}(U)} M_\alpha$.
Fix $\alpha$ and $s''$.
Choose a presentation
$$
\mathcal{O}(U)^{\oplus m} \xrightarrow{A} \mathcal{O}(U)^{\oplus n}
\to M_\alpha \to 0
$$
We apply (3) to the corresponding complex of $\mathcal{O}_U$-modules
$$
\mathcal{O}_U^{\oplus m} \xrightarrow{A}
\mathcal{O}_U^{\oplus n} \xrightarrow{(s_1, \ldots, s_n)}
\mathcal{F}|_U
$$
After replacing $U$ by the members of the covering $U_i$
we find that the map
$$
M_\alpha \to \mathcal{F}(U)
$$
factors through a free module $\mathcal{O}(U)^{\oplus l}$ for some $l$.
Since $\mathcal{G}(U) \to \mathcal{H}(U)$ is injective
we conclude that
$$
\mathcal{G}(U) \otimes_{\mathcal{O}(U)} \mathcal{O}(U)^{\oplus l}
\to
\mathcal{H}(U) \otimes_{\mathcal{O}(U)} \mathcal{O}(U)^{\oplus l}
$$
is injective too. Hence as $s''$ maps to zero in the module on
the right, it also maps to zero in the module on the left, i.e.,
$s$ is zero as desired.
\end{proof}

\begin{lemma}
\label{lemma-flat-over-thickening}
Let $\mathcal{C}$ be a site. Let $\mathcal{O}' \to \mathcal{O}$
be a surjection of sheaves of rings whose kernel $\mathcal{I}$ is
an ideal of square zero. Let $\mathcal{F}'$ be an $\mathcal{O}'$-module
and set $\mathcal{F} = \mathcal{F}'/\mathcal{I}\mathcal{F}'$.
The following are equivalent
\begin{enumerate}
\item $\mathcal{F}'$ is a flat $\mathcal{O}'$-module, and
\item $\mathcal{F}$ is a flat $\mathcal{O}$-module and
$\mathcal{I} \otimes_\mathcal{O} \mathcal{F} \to \mathcal{F}'$
is injective.
\end{enumerate}
\end{lemma}

\begin{proof}
If (1) holds, then
$\mathcal{F} = \mathcal{F}' \otimes_{\mathcal{O}'} \mathcal{O}$ is
flat over $\mathcal{O}$ by
Lemma \ref{lemma-flat-change-of-rings}
and we see the map
$\mathcal{I} \otimes_\mathcal{O} \mathcal{F} \to \mathcal{F}'$
is injective by applying $- \otimes_{\mathcal{O}'} \mathcal{F}'$
to the exact sequence
$0 \to \mathcal{I} \to \mathcal{O}' \to \mathcal{O} \to 0$, see
Lemma \ref{lemma-flat-tor-zero}.
Assume (2). In the rest of the proof we will use without further mention
that $\mathcal{K} \otimes_{\mathcal{O}'} \mathcal{F}' =
\mathcal{K} \otimes_\mathcal{O} \mathcal{F}$
for any $\mathcal{O}'$-module $\mathcal{K}$ annihilated by $\mathcal{I}$.
Let $\alpha : \mathcal{G}' \to \mathcal{H}'$
be an injective map of $\mathcal{O}'$-modules. Let
$\mathcal{G} \subset \mathcal{G}'$, resp.\ $\mathcal{H} \subset \mathcal{H}'$
be the subsheaf of sections annihilated by $\mathcal{I}$.
Consider the diagram
$$
\xymatrix{
\mathcal{G} \otimes_{\mathcal{O}'} \mathcal{F}' \ar[r] \ar[d] &
\mathcal{G}' \otimes_{\mathcal{O}'} \mathcal{F}' \ar[r] \ar[d] &
\mathcal{G}'/\mathcal{G} \otimes_{\mathcal{O}'} \mathcal{F}' \ar[r] \ar[d] &
0 \\
\mathcal{H} \otimes_{\mathcal{O}'} \mathcal{F}' \ar[r] &
\mathcal{H}' \otimes_{\mathcal{O}'} \mathcal{F}' \ar[r] &
\mathcal{H}'/\mathcal{H} \otimes_{\mathcal{O}'} \mathcal{F}' \ar[r] & 0
}
$$
Note that $\mathcal{G}'/\mathcal{G}$ and $\mathcal{H}'/\mathcal{H}$
are annihilated by $\mathcal{I}$ and that
$\mathcal{G}'/\mathcal{G} \to \mathcal{H}'/\mathcal{H}$ is injective.
Thus the right vertical arrow is injective as $\mathcal{F}$ is flat
over $\mathcal{O}$. The same is true for the left vertical arrow.
Hence the middle vertical arrow is injective and $\mathcal{F}'$ is flat.
\end{proof}

\begin{lemma}
\label{lemma-neighbourhood-isomorphism}
Let $\mathcal{C}$ be a site. Let $\mathcal{O} \to \mathcal{O}'$
be a flat homomorphism of sheaves of rings. Let
$\mathcal{I} \subset \mathcal{O}$
be a sheaf of ideals such that the induced map
$\mathcal{O}/\mathcal{I} \to \mathcal{O}'/\mathcal{I}\mathcal{O}'$
is an isomorphism. For any $\mathcal{O}$-module $\mathcal{F}$
annihilated by $\mathcal{I}^n$ for some $n \geq 0$ the map
$\text{id} \otimes 1 :
\mathcal{F} \to \mathcal{F} \otimes_\mathcal{O} \mathcal{O}'$
is an isomorphism.
\end{lemma}

\begin{proof}
Omitted. Hint: See More on Algebra, Lemma
\ref{more-algebra-lemma-neighbourhood-isomorphism}.
\end{proof}





\section{Duals}
\label{section-duals}

\noindent
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. The category of
$\mathcal{O}$-modules endowed with the tensor product
constructed in Section \ref{section-tensor-product}
is a symmetric monoidal category. For an $\mathcal{O}$-module
$\mathcal{F}$ the following are equivalent
\begin{enumerate}
\item $\mathcal{F}$ has a left dual in the monoidal category
of $\mathcal{O}$-modules,
\item for every object $U$ of $\mathcal{C}$ there exists a covering
$\{U_i \to U\}$ such that $\mathcal{F}|_{U_i}$ is a direct summand
of a finite free $\mathcal{O}|_{U_i}$-module, and
\item $\mathcal{F}$ is of finite presentation and flat as an
$\mathcal{O}$-module.
\end{enumerate}
This is proved in Example \ref{example-dual} and
Lemmas \ref{lemma-left-dual-module} and
\ref{lemma-flat-locally-finite-presentation} of this section.

\begin{example}
\label{example-dual}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let $\mathcal{F}$
be an $\mathcal{O}$-module such that for every object $U$ of $\mathcal{C}$
there exists a covering $\{U_i \to U\}$ such that $\mathcal{F}|_{U_i}$
is a direct summand of a finite free $\mathcal{O}|_{U_i}$-module.
Then the map
$$
\mathcal{F} \otimes_\mathcal{O}
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{O})
\longrightarrow
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{F})
$$
is an isomorphism. Namely, this is a local question, it is true
if $\mathcal{F}$ is finite free, and it holds for any summand
of a module for which it is true (details omitted). Denote
$$
\eta :
\mathcal{O}
\longrightarrow
\mathcal{F} \otimes_\mathcal{O}
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{O})
$$
the map sending $1$ to the section corresponding to
$\text{id}_\mathcal{F}$ under the isomorphism above.
Denote
$$
\epsilon : 
\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{O})
\otimes_\mathcal{O} \mathcal{F}
\longrightarrow
\mathcal{O}
$$
the evaluation map. Then we see that
$\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{O}), \eta, \epsilon$
is a left dual for $\mathcal{F}$ as in
Categories, Definition \ref{categories-definition-dual}.
We omit the verification that
$(1 \otimes \epsilon) \circ (\eta \otimes 1) = \text{id}_\mathcal{F}$
and
$(\epsilon \otimes 1) \circ (1 \otimes \eta) =
\text{id}_{\SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{O})}$.
\end{example}

\begin{lemma}
\label{lemma-left-dual-module}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let $\mathcal{F}$ be a
$\mathcal{O}$-module. Let $\mathcal{G}, \eta, \epsilon$
be a left dual of $\mathcal{F}$ in the monoidal category of
$\mathcal{O}$-modules, see
Categories, Definition \ref{categories-definition-dual}. Then
\begin{enumerate}
\item for every object $U$ of $\mathcal{C}$
there exists a covering $\{U_i \to U\}$ such that $\mathcal{F}|_{U_i}$
is a direct summand of a finite free $\mathcal{O}|_{U_i}$-module,
\item the map
$e : \SheafHom_\mathcal{O}(\mathcal{F}, \mathcal{O}) \to \mathcal{G}$
sending a local section $\lambda$ to $(\lambda \otimes 1)(\eta)$
is an isomorphism,
\item we have $\epsilon(f, g) = e^{-1}(g)(f)$ for local sections
$f$ and $g$ of $\mathcal{F}$ and $\mathcal{G}$.
\end{enumerate}
\end{lemma}

\begin{proof}
The assumptions mean that
$$
\mathcal{F} \xrightarrow{\eta \otimes 1}
\mathcal{F} \otimes_\mathcal{O} \mathcal{G}
\otimes_\mathcal{O} \mathcal{F}
\xrightarrow{1 \otimes \epsilon} \mathcal{F}
\quad\text{and}\quad
\mathcal{G} \xrightarrow{1 \otimes \eta}
\mathcal{G} \otimes_\mathcal{O} \mathcal{F}
\otimes_\mathcal{O} \mathcal{G}
\xrightarrow{\epsilon \otimes 1} \mathcal{G}
$$
are the identity map. Let $U$ be an object of $\mathcal{C}$.
After replacing $U$ by the members of a covering of $U$,
we can find a finite number of sections $f_1, \ldots, f_n$
and $g_1, \ldots, g_n$ of
$\mathcal{F}$ and $\mathcal{G}$ over $U$ such that
$\eta(1) = \sum f_i g_i$. Denote
$$
\mathcal{O}_U^{\oplus n} \to \mathcal{F}|_U
$$
the map sending the $i$th basis vector to $f_i$. Then we
can factor the map $\eta|_U$ over a map
$\tilde \eta : \mathcal{O}_U \to
\mathcal{O}_U^{\oplus n} \otimes_{\mathcal{O}_U} \mathcal{G}|_U$.
We obtain a commutative diagram
$$
\xymatrix{
\mathcal{F}|_U
\ar[rr]_-{\eta \otimes 1} \ar[rrd]_-{\tilde \eta \otimes 1} & &
\mathcal{F}|_U \otimes \mathcal{G}|_U \otimes \mathcal{F}|_U
\ar[r]_-{1 \otimes \epsilon} &
\mathcal{F}|_U \\
& &
\mathcal{O}_U^{\oplus n} \otimes \mathcal{G}|_U \otimes \mathcal{F}|_U
\ar[u] \ar[r]^-{1 \otimes \epsilon} &
\mathcal{O}_U^{\oplus n} \ar[u]
}
$$
This shows that the identity on $\mathcal{F}|_U$
factors through a finite free $\mathcal{O}_U$-module.
This proves (1). Part (2) follows from
Categories, Lemma \ref{categories-lemma-left-dual} and its proof.
Part (3) follows from the first equality of the proof.
You can also deduce (2) and (3) from the uniqueness of left duals
(Categories, Remark \ref{categories-remark-left-dual-adjoint})
and the construction of the left dual in
Example \ref{example-dual}.
\end{proof}

\begin{lemma}
\label{lemma-flat-locally-finite-presentation}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let $\mathcal{F}$
be locally of finite presentation and flat. Then given an object
$U$ of $\mathcal{C}$ there exists a covering $\{U_i \to U\}$ such that
$\mathcal{F}|_{U_i}$ is a direct summand of a finite free
$\mathcal{O}_{U_i}$-module.
\end{lemma}

\begin{proof}
Choose an object $U$ of $\mathcal{C}$.
After replacing $U$ by the members of a covering, we may
assume there exists a presentation
$$
\mathcal{O}_U^{\oplus r} \to
\mathcal{O}_U^{\oplus n} \to \mathcal{F}|_U \to 0
$$
By Lemma \ref{lemma-flat-eq} we may, after replacing $U$
by the members of a covering, assume there exists a factorization
$$
\mathcal{O}_U^{\oplus n} \to
\mathcal{O}_U^{\oplus n_1} \to \mathcal{F}|_U
$$
such that the composition
$\mathcal{O}_U^{\oplus r} \to \mathcal{O}_U^{\oplus n}
\to \mathcal{O}_U^{\oplus n_r}$ is zero.
This means that the surjection $\mathcal{O}_U^{\oplus n_r} \to \mathcal{F}|_U$
has a section and we win.
\end{proof}











\section{Towards constructible modules}
\label{section-constructible}

\noindent
Recall that a quasi-compact object of a site is roughly an object
such that every covering of it can be refined by a finite covering
(the actual definition is slightly more involved, see
Sites, Section \ref{sites-section-quasi-compact}). It turns out that
if every object of a site has a covering by quasi-compact objects, then
the modules $j_!\mathcal{O}_U$ with $U$ quasi-compact form a particularly
nice set of generators for the category of all modules.

\begin{lemma}
\label{lemma-covering-gives-surjection}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let $\{U_i \to U\}$
be a covering of $\mathcal{C}$. Then the sequence
$$
\bigoplus j_{U_i \times_U U_j!}\mathcal{O}_{U_i \times_U U_j} \to
\bigoplus j_{U_i!}\mathcal{O}_{U_i} \to j_!\mathcal{O}_U \to 0
$$
is exact.
\end{lemma}

\begin{proof}
For any $\mathcal{O}$-module $\mathcal{F}$ the functor
$\Hom_\mathcal{O}(-, \mathcal{F})$ turns our sequence into the exact sequence
$0 \to \mathcal{F}(U) \to \prod \mathcal{F}(U_i) \to
\prod \mathcal{F}(U_i \times_U U_j)$, see
(\ref{equation-map-lower-shriek-OU-into-module}). The lemma follows from
this and
Homology, Lemma \ref{homology-lemma-check-exactness}.
\end{proof}

\begin{lemma}
\label{lemma-silly-quasi-compact}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let
$\mathcal{U} = \{U_i \to U\}_{i \in I}$ be covering of $\mathcal{C}$.
If $U$ is quasi-compact, then there exist a finite subset
$I' \subset I$ such that the sequence
$$
\bigoplus\nolimits_{i, i' \in I'}
j_{U_i \times_U U_{i'}!}\mathcal{O}_{U_i \times_U U_{i'}} \to
\bigoplus\nolimits_{i \in I'}
j_{U_i!}\mathcal{O}_{U_i} \to
j_!\mathcal{O}_U \to 0
$$
is exact.
\end{lemma}

\begin{proof}
This lemma is immediate from Lemma \ref{lemma-covering-gives-surjection}
if $U$ satisfies condition (3) of
Sites, Lemma \ref{sites-lemma-conclude-quasi-compact}.
We urge the reader to skip the proof in the general case.
By definition there exists a covering
$\mathcal{V} = \{V_j \to U\}_{j \in J}$ and a morphism
$\mathcal{V} \to \mathcal{U}$ of families of maps with fixed target
given by $\text{id} : U \to U$, $\alpha : J \to I$, and
$f_j : V_j \to U_{\alpha(j)}$
(see Sites, Definition \ref{sites-definition-morphism-coverings})
such that the image $I' \subset I$ of $\alpha$ is finite.
By Homology, Lemma \ref{homology-lemma-check-exactness}
it suffices to show that for any sheaf of $\mathcal{O}$-modules $\mathcal{F}$
the functor $\Hom_\mathcal{O}(-, \mathcal{F})$ turns the sequence
of the lemma into an exact sequence. By
(\ref{equation-map-lower-shriek-OU-into-module})
we obtain the usual sequence
$$
0 \to
\mathcal{F}(U) \to
\prod\nolimits_{i \in I'} \mathcal{F}(U_i) \to
\prod\nolimits_{i, i' \in I'} \mathcal{F}(U_i \times_U U_{i'})
$$
This is an exact sequence by
Sites, Lemma \ref{sites-lemma-compare-sheaf-condition}
applied to the family of maps $\{U_i \to U\}_{i \in I'}$
which is refined by the covering $\mathcal{V}$.
\end{proof}

\begin{lemma}
\label{lemma-sections-over-quasi-compact}
Let $\mathcal{C}$ be a site. Let $W$ be a quasi-compact
object of $\mathcal{C}$.
\begin{enumerate}
\item The functor $\Sh(\mathcal{C}) \to \textit{Sets}$,
$\mathcal{F} \mapsto \mathcal{F}(W)$ commutes with coproducts.
\item Let $\mathcal{O}$ be a sheaf of rings on $\mathcal{C}$. The functor
$\textit{Mod}(\mathcal{O}) \to \textit{Ab}$,
$\mathcal{F} \mapsto \mathcal{F}(W)$
commutes with direct sums.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). Taking sections over $W$ commutes with filtered colimits
with injective transition maps by
Sites, Lemma \ref{sites-lemma-directed-colimits-sections}.
If $\mathcal{F}_i$ is a family of sheaves of sets
indexed by a set $I$. Then $\coprod \mathcal{F}_i$ is the filtered
colimit over the partially ordered set of finite subsets
$E \subset I$ of the coproducts
$\mathcal{F}_E = \coprod_{i \in E} \mathcal{F}_i$.
Since the transition maps are injective we conclude.

\medskip\noindent
Proof of (2).
Let $\mathcal{F}_i$ be a family of sheaves of $\mathcal{O}$-modules
indexed by a set $I$. Then $\bigoplus \mathcal{F}_i$ is the filtered
colimit over the partially ordered set of finite subsets
$E \subset I$ of the direct sums
$\mathcal{F}_E = \bigoplus_{i \in E} \mathcal{F}_i$.
A filtered colimit of abelian sheaves can be computed in the
category of sheaves of sets. Moreover, for $E \subset E'$ the transition map
$\mathcal{F}_E \to \mathcal{F}_{E'}$ is injective (as sheafification
is exact and the injectivity is clear on underlying presheaves).
Hence it suffices to show the result for a finite index set by
Sites, Lemma \ref{sites-lemma-directed-colimits-sections}.
The finite case is dealt with in
Lemma \ref{lemma-limits-colimits-abelian-sheaves}
(it holds over any object of $\mathcal{C}$).
\end{proof}

\begin{lemma}
\label{lemma-quasi-compact-hom-from}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let $U$ be a quasi-compact
object of $\mathcal{C}$. Then the functor
$\Hom_\mathcal{O}(j_!\mathcal{O}_U, -)$ commutes with direct sums.
\end{lemma}

\begin{proof}
This is true because
$\Hom_\mathcal{O}(j_!\mathcal{O}_U, \mathcal{F}) = \mathcal{F}(U)$
by (\ref{equation-map-lower-shriek-OU-into-module})
and because the functor $\mathcal{F} \mapsto \mathcal{F}(U)$
commutes with direct sums by
Lemma \ref{lemma-sections-over-quasi-compact}.
\end{proof}

\noindent
In order to state the sharpest possible results in the following
we introduce some notation.

\begin{situation}
\label{situation-quasi-compact-objects}
Let $\mathcal{C}$ be a site. Let
$\mathcal{B} \subset \text{Ob}(\mathcal{C})$ be a set
of objects. We consider the following conditions
\begin{enumerate}
\item
\label{item-enough}
Every object of $\mathcal{C}$ has a covering by elements of $\mathcal{B}$.
\item
\label{item-enough-qc}
Every $U \in \mathcal{B}$ is quasi-compact
(Sites, Section \ref{sites-section-quasi-compact}).
\item
\label{item-enough-qc-qs}
For a covering $\{U_i \to U\}$ with $U_i, U \in \mathcal{B}$
the fibre products $U_i \times_U U_j$ are quasi-compact.
\end{enumerate}
\end{situation}

\begin{lemma}
\label{lemma-module-quotient-direct-sum}
In Situation \ref{situation-quasi-compact-objects} assume
(\ref{item-enough}) holds.
\begin{enumerate}
\item Every sheaf of sets is the target of a surjective map
whose source is a coproduct $\coprod h_{U_i}^\#$ with $U_i$ in $\mathcal{B}$.
\item If $\mathcal{O}$ is a sheaf of rings, then every $\mathcal{O}$-module
is a quotient of a direct sum $\bigoplus\nolimits j_{U_i!}\mathcal{O}_{U_i}$
with $U_i$ in $\mathcal{B}$.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) follows from Sites, Lemmas
\ref{sites-lemma-sheaf-coequalizer-representable} and
\ref{sites-lemma-covering-surjective-after-sheafification}.
Part (2) follows from Lemmas \ref{lemma-module-quotient-flat} and
\ref{lemma-covering-gives-surjection}.
\end{proof}

\begin{lemma}
\label{lemma-module-filtered-colimit-constructibles}
In Situation \ref{situation-quasi-compact-objects} assume
(\ref{item-enough}) and (\ref{item-enough-qc}) hold.
\begin{enumerate}
\item Every sheaf of sets is a filtered colimit of sheaves of the form
\begin{equation}
\label{equation-towards-constructible-sets}
\text{Coequalizer}\left(
\xymatrix{
\coprod\nolimits_{j = 1, \ldots, m} h_{V_j}^\#
\ar@<1ex>[r] \ar@<-1ex>[r] &
\coprod\nolimits_{i = 1, \ldots, n} h_{U_i}^\#
}
\right)
\end{equation}
with $U_i$ and $V_j$ in $\mathcal{B}$.
\item If $\mathcal{O}$ is a sheaf of rings, then every $\mathcal{O}$-module
is a filtered colimit of sheaves of the form
\begin{equation}
\label{equation-towards-constructible}
\Coker\left(
\bigoplus\nolimits_{j = 1, \ldots, m} j_{V_j!}\mathcal{O}_{V_j}
\longrightarrow
\bigoplus\nolimits_{i = 1, \ldots, n} j_{U_i!}\mathcal{O}_{U_i}
\right)
\end{equation}
with $U_i$ and $V_j$ in $\mathcal{B}$.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). By Lemma \ref{lemma-module-quotient-direct-sum}
every sheaf of sets $\mathcal{F}$ is the target of a surjection
whose source is a coprod $\mathcal{F}_0$
of sheaves the form $h_{U}^\#$ with $U \in \mathcal{B}$.
Applying this to $\mathcal{F}_0 \times_\mathcal{F} \mathcal{F}_0$
we find that $\mathcal{F}$ is a coequalizer of a pair of maps
$$
\xymatrix{
\coprod\nolimits_{j \in J} h_{V_j}^\#
\ar@<1ex>[r] \ar@<-1ex>[r] &
\coprod\nolimits_{i \in I} h_{U_i}^\#
}
$$
for some index sets $I$, $J$ and $V_j$ and $U_i$ in $\mathcal{B}$.
For every finite subset $J' \subset J$ there is a finite subset
$I' \subset I$ such that the coproduct over $j \in J'$ maps into
the coprod over $i \in I'$ via both maps, see
Sites, Lemma \ref{sites-lemma-directed-colimits-sections}.
(Details omitted; hint: an infinite coproduct is the filtered colimit
of the finite sub-coproducts.)
Thus our sheaf is the colimit of the cokernels of these maps
between finite coproducts.

\medskip\noindent
Proof of (2).
By Lemma \ref{lemma-module-quotient-direct-sum}
every module is a quotient of a direct sum of modules of the form
$j_{U!}\mathcal{O}_U$ with $U \in \mathcal{B}$. Thus every module
is a cokernel
$$
\Coker\left(
\bigoplus\nolimits_{j \in J} j_{V_j!}\mathcal{O}_{V_j}
\longrightarrow
\bigoplus\nolimits_{i \in I} j_{U_i!}\mathcal{O}_{U_i}
\right)
$$
for some index sets $I$, $J$ and $V_j$ and $U_i$ in $\mathcal{B}$.
For every finite subset $J' \subset J$ there is a finite subset
$I' \subset I$ such that the direct sum over $j \in J'$ maps into
the direct sum over $i \in I'$, see
Lemma \ref{lemma-quasi-compact-hom-from}.
Thus our module is the colimit of the cokernels of these maps
between finite direct sums.
\end{proof}

\begin{lemma}
\label{lemma-cokernel-map-towards-constructibles}
In Situation \ref{situation-quasi-compact-objects} assume
(\ref{item-enough}) and (\ref{item-enough-qc}) hold.
Let $\mathcal{O}$ be a sheaf of rings.
Then a cokernel of a map between modules as in
(\ref{equation-towards-constructible}) is another module as
in (\ref{equation-towards-constructible}).
\end{lemma}

\begin{proof}
Let $\mathcal{F} = \Coker(\bigoplus j_{V_j!}\mathcal{O}_{V_j} \to
\bigoplus j_{U_i!}\mathcal{O}_{U_i})$
as in (\ref{equation-towards-constructible}). It suffices to show
that the cokernel of a map $\varphi : j_{W!}\mathcal{O}_W \to \mathcal{F}$
with $W \in \mathcal{B}$ is another module of the same type.
The map $\varphi$ corresponds to $s \in \mathcal{F}(W)$.
Since $\bigoplus j_{U_i!}\mathcal{O}_{U_i} \to \mathcal{F}$ is
surjective, by (\ref{item-enough}) we may choose a covering
$\{W_k \to W\}_{k \in K}$ with $W_k \in \mathcal{B}$
such that $s|_{W_k}$ is the image of some section
$s_k$ of $\bigoplus j_{U_i!}\mathcal{O}_{U_i})$.
By (\ref{item-enough-qc}) the object $W$ is quasi-compact.
By Lemma \ref{lemma-silly-quasi-compact}
there is a finite subset $K' \subset K$ such that
$\bigoplus_{k \in K'} j_{W_k!}\mathcal{O}_{W_k} \to j_{W!}\mathcal{O}_W$
is surjective. We conclude that $\Coker(\varphi)$ is equal to
$$
\Coker\left(
\bigoplus\nolimits_{k \in K'} j_{W_k!}\mathcal{O}_{W_k} \oplus
\bigoplus j_{V_j!}\mathcal{O}_{V_j}
\longrightarrow
\bigoplus j_{U_i!}\mathcal{O}_{U_i}
\right)
$$
where the map $\bigoplus_{k \in K'} j_{W_k!}\mathcal{O}_{W_k}
\to \bigoplus j_{U_i!}\mathcal{O}_{U_i}$ corresponds to
$\sum_{k \in K'} s_k$. This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-change-presentation-towards-constructibles}
In Situation \ref{situation-quasi-compact-objects} assume
(\ref{item-enough}), (\ref{item-enough-qc}), and (\ref{item-enough-qc-qs})
hold. Let $\mathcal{O}$ be a sheaf of rings. Assume given a map
$$
\bigoplus\nolimits_{j = 1, \ldots, m} j_{V_j!}\mathcal{O}_{V_j}
\longrightarrow
\bigoplus\nolimits_{i = 1, \ldots, n} j_{U_i!}\mathcal{O}_{U_i}
$$
with $U_i$ and $V_j$ in $\mathcal{B}$, and coverings
$\{U_{ik} \to U_i\}_{k \in K_i}$ with $U_{ik} \in \mathcal{B}$.
Then there exist finite subsets $K'_i \subset K_i$ and
a finite set $L$ of $W_l \in \mathcal{B}$ and a commutative diagram
$$
\xymatrix{
\bigoplus_{l \in L} j_{W_l!}\mathcal{O}_{W_l} \ar[d] \ar[r] &
\bigoplus_{i = 1, \ldots, n} \bigoplus_{k \in K'_i}
j_{U_{ik}!}\mathcal{O}_{U_{ik}} \ar[d] \\
\bigoplus_{j = 1, \ldots, m} j_{V_j!}\mathcal{O}_{V_j} \ar[r] &
\bigoplus_{i = 1, \ldots, n} j_{U_i!}\mathcal{O}_{U_i}
}
$$
inducing an isomorphism on cokernels of the horizontal maps.
\end{lemma}

\begin{proof}
Since $U_i$ is quasi-compact, we may choose finite subsets $K'_i \subset K_i$
as in Lemma \ref{lemma-silly-quasi-compact}.
Then since
$\bigoplus_{i = 1, \ldots, n}
\bigoplus_{k \in K'_i} j_{U_{ik}!}\mathcal{O}_{U_{ik}} \to
\bigoplus_{i = 1, \ldots, n} j_{U_i!}\mathcal{O}_{U_i}$ is surjective,
we can find coverings $\{V_{jm} \to V_j\}_{m \in M_j}$ with
$V_{jm} \in \mathcal{B}$ such that we can find a commutative diagram
$$
\xymatrix{
\bigoplus_{j = 1, \ldots, m} \bigoplus_{m \in M_j}
j_{V_{jm}!}\mathcal{O}_{V_{jm}} \ar[d] \ar[r] &
\bigoplus_{i = 1, \ldots n} \bigoplus_{k \in K'_i}
j_{U_{ik}!}\mathcal{O}_{U_{ik}} \ar[d] \\
\bigoplus_{j = 1, \ldots, m} j_{V_j!}\mathcal{O}_{V_j} \ar[r] &
\bigoplus_{i = 1, \ldots, n} j_{U_i!}\mathcal{O}_{U_i}
}
$$
Since $V_j$ is quasi-compact, we can choose finite subsets
$M'_j \subset M_j$ as in Lemma \ref{lemma-silly-quasi-compact}.
Set
$$
L = \left(\coprod\nolimits_{i = 1, \ldots, n} K'_i \times K'_i \right)
\coprod
\left(\coprod\nolimits_{j = 1, \ldots, m} M'_j\right)
$$
and for $l = (k, k') \in K'_i \times K'_i \subset L$ set
$W_l = U_{ik} \times_{U_i} U_{ik'}$ and for
$l = m \in M'_j \subset L$ set $W_l = V_{jm}$.
Since we have the exact sequences of Lemma \ref{lemma-silly-quasi-compact}
for the families $\{U_{ik} \to U_i\}_{k \in K'_i}$
we conclude that we get a diagram as in the statement of the lemma
(details omitted), except that it is not yet clear that $W_l \in \mathcal{B}$.
However, since $W_l$ is quasi-compact for all $l \in L$
we do another application of Lemma \ref{lemma-silly-quasi-compact}
and find finite families of maps $\{W_{lt} \to W_l\}_{t \in T_l}$
with $W_{lt} \in \mathcal{B}$ such that
$\bigoplus j_{W_{lt}!}\mathcal{O}_{W_{lt}} \to j_{W_l!}\mathcal{O}_{W_l}$
is surjective. Then we replace $L$ by $\coprod_{l \in L} T_l$
and everything is clear.
\end{proof}

\begin{lemma}
\label{lemma-extension-towards-constructibles}
In Situation \ref{situation-quasi-compact-objects} assume
(\ref{item-enough}), (\ref{item-enough-qc}), and (\ref{item-enough-qc-qs})
hold. Let $\mathcal{O}$ be a sheaf of rings.
Then an extension of modules as in (\ref{equation-towards-constructible})
is another module as in (\ref{equation-towards-constructible}).
\end{lemma}

\begin{proof}
Let $0 \to \mathcal{F}_1 \to \mathcal{F}_2 \to \mathcal{F}_3 \to 0$
be a short exact sequence of $\mathcal{O}$-modules with
$\mathcal{F}_1$ and $\mathcal{F}_3$ as in
(\ref{equation-towards-constructible}). Choose presentations
$$
\bigoplus A_{V_j} \to \bigoplus A_{U_i} \to \mathcal{F}_1 \to 0
\quad\text{and}\quad
\bigoplus A_{T_j} \to \bigoplus A_{W_i} \to \mathcal{F}_3 \to 0
$$
In this proof the direct sums are always finite, and
we write $A_U = j_{U!}\mathcal{O}_U$ for $U \in \mathcal{B}$.
Since $\mathcal{F}_2 \to \mathcal{F}_3$ is surjective, we can
choose coverings $\{W_{ik} \to W_i\}$ with $W_{ik} \in \mathcal{B}$
such that $A_{W_{ik}} \to \mathcal{F}_3$ lifts to a map
$A_{W_{ik}} \to \mathcal{F}_2$.
By Lemma \ref{lemma-change-presentation-towards-constructibles}
we may replace our collection $\{W_i\}$ by a finite subcollection
of the collection $\{W_{ik}\}$ and assume the map
$\bigoplus A_{W_i} \to \mathcal{F}_3$ lifts to a map into $\mathcal{F}_2$.
Consider the kernel
$$
\mathcal{K}_2 = \Ker(\bigoplus A_{U_i} \oplus \bigoplus A_{W_i}
\longrightarrow \mathcal{F}_2)
$$
By the snake lemma this kernel surjects onto
$\mathcal{K}_3 = \Ker(\bigoplus A_{W_i} \to \mathcal{F}_3)$.
Thus, arguing as above, after replacing each $T_j$ by a finite family of
elements of $\mathcal{B}$ (permissible by
Lemma \ref{lemma-silly-quasi-compact})
we may assume there is a map
$\bigoplus A_{T_j} \to \mathcal{K}_2$ lifting the given map
$\bigoplus A_{T_j} \to \mathcal{K}_3$.
Then $\bigoplus A_{V_j} \oplus \bigoplus A_{T_j} \to \mathcal{K}_2$
is surjective which finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-towards-constructible-when-serre-subcategory}
In Situation \ref{situation-quasi-compact-objects} assume
(\ref{item-enough}), (\ref{item-enough-qc}), and (\ref{item-enough-qc-qs})
hold. Let $\mathcal{O}$ be a sheaf of rings.
Let $\mathcal{A} \subset \textit{Mod}(\mathcal{O})$ be the full
subcategory of modules isomorphic to a cokernel as in
(\ref{equation-towards-constructible}).
If the kernel of every map of $\mathcal{O}$-modules of the form
$$
\bigoplus\nolimits_{j = 1, \ldots, m} j_{V_j!}\mathcal{O}_{V_j}
\longrightarrow
\bigoplus\nolimits_{i = 1, \ldots, n} j_{U_i!}\mathcal{O}_{U_i}
$$
with $U_i$ and $V_j$ in $\mathcal{B}$, is in $\mathcal{A}$, then
$\mathcal{A}$ is weak Serre subcategory of $\textit{Mod}(\mathcal{O})$.
\end{lemma}

\begin{proof}
We will use the criterion of
Homology, Lemma \ref{homology-lemma-characterize-weak-serre-subcategory}.
By the results of
Lemmas \ref{lemma-cokernel-map-towards-constructibles} and
\ref{lemma-extension-towards-constructibles}
it suffices to see that the kernel of a map $\mathcal{F} \to \mathcal{G}$
between objects of $\mathcal{A}$ is in $\mathcal{A}$. To prove this
choose presentations
$$
\bigoplus A_{V_j} \to \bigoplus A_{U_i} \to \mathcal{F} \to 0
\quad\text{and}\quad
\bigoplus A_{T_j} \to \bigoplus A_{W_i} \to \mathcal{G} \to 0
$$
In this proof the direct sums are always finite, and
we write $A_U = j_{U!}\mathcal{O}_U$ for $U \in \mathcal{B}$.
Using Lemmas \ref{lemma-covering-gives-surjection} and
\ref{lemma-change-presentation-towards-constructibles}
and arguing as in the proof of
Lemma \ref{lemma-extension-towards-constructibles}
we may assume that the map $\mathcal{F} \to \mathcal{G}$
lifts to a map of presentations
$$
\xymatrix{
\bigoplus A_{V_j} \ar[r] \ar[d] &
\bigoplus A_{U_i} \ar[r] \ar[d] &
\mathcal{F} \ar[r] \ar[d] & 0 \\
\bigoplus A_{T_j} \ar[r] &
\bigoplus A_{W_i} \ar[r] &
\mathcal{G} \ar[r] & 0
}
$$
Then we see that
$$
\Ker(\mathcal{F} \to \mathcal{G}) =
\Coker\left(\bigoplus A_{V_j} \to
\Ker\left(
\bigoplus A_{T_j} \oplus \bigoplus A_{U_i} \to \bigoplus A_{W_i}\right)\right)
$$
and the lemma follows from the assumption and
Lemma \ref{lemma-cokernel-map-towards-constructibles}.
\end{proof}








\section{Flat morphisms}
\label{section-flat-morphisms}

\begin{definition}
\label{definition-flat-morphism}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O})
\longrightarrow
(\Sh(\mathcal{C}'), \mathcal{O}')$
be a morphism of ringed topoi. We say $(f, f^\sharp)$ is
{\it flat} if the ring map $f^\sharp : f^{-1}\mathcal{O}' \to \mathcal{O}$
is flat. We say a morphism of ringed sites is {\it flat}
if the associated morphism of ringed topoi is flat.
\end{definition}

\begin{lemma}
\label{lemma-flat-pullback-exact}
Let $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{C}')$
be a morphism of ringed topoi. Then
$$
f^{-1} : \textit{Ab}(\mathcal{C}') \longrightarrow \textit{Ab}(\mathcal{C}),
\quad
\mathcal{F} \longmapsto f^{-1}\mathcal{F}
$$
is exact. If
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O})
\to
(\Sh(\mathcal{C}'), \mathcal{O}')$
is a flat morphism of ringed topoi then
$$
f^* : \textit{Mod}(\mathcal{O}') \longrightarrow \textit{Mod}(\mathcal{O}),
\quad
\mathcal{F} \longmapsto f^*\mathcal{F}
$$
is exact.
\end{lemma}

\begin{proof}
Given an abelian sheaf $\mathcal{G}$ on $\mathcal{C}'$
the underlying sheaf of sets of $f^{-1}\mathcal{G}$ is the same
as $f^{-1}$ of the underlying sheaf of sets of $\mathcal{G}$, see
Sites, Section \ref{sites-section-sheaves-algebraic-structures}.
Hence the exactness of $f^{-1}$ for sheaves of sets (required in the
definition of a morphism of topoi, see
Sites, Definition \ref{sites-definition-topos})
implies the exactness of $f^{-1}$ as a functor on abelian sheaves.

\medskip\noindent
To see the statement on modules recall that $f^*\mathcal{F}$ is defined
as the tensor product
$f^{-1}\mathcal{F} \otimes_{f^{-1}\mathcal{O}', f^\sharp} \mathcal{O}$.
Hence $f^*$ is a composition of functors both of which are exact.
\end{proof}

\begin{definition}
\label{definition-flat-module}
Let $f : (\Sh(\mathcal{C}), \mathcal{O}) \to (\Sh(\mathcal{D}), \mathcal{O}')$
be a morphism of ringed topoi. Let $\mathcal{F}$ be a sheaf of
$\mathcal{O}$-modules. We say that $\mathcal{F}$ is
{\it flat over $(\Sh(\mathcal{D}), \mathcal{O}')$} if
$\mathcal{F}$ is flat as an $f^{-1}\mathcal{O}'$-module.
\end{definition}

\noindent
This is compatible with the notion as defined for morphisms of ringed spaces,
see Modules, Definition \ref{modules-definition-flat-module}
and the discussion following.

\begin{lemma}
\label{lemma-pullback-internal-hom}
Let $f : (\mathcal{C}, \mathcal{O}_\mathcal{C}) \to
(\mathcal{D}, \mathcal{O}_\mathcal{D})$ be a morphism
of ringed sites. Let $\mathcal{F}$, $\mathcal{G}$ be
$\mathcal{O}_\mathcal{D}$-modules.
If $\mathcal{F}$ is finitely presented and $f$ is flat,
then the canonical map
$$
f^*\SheafHom_{\mathcal{O}_\mathcal{D}}(\mathcal{F}, \mathcal{G})
\longrightarrow
\SheafHom_{\mathcal{O}_\mathcal{C}}(f^*\mathcal{F}, f^*\mathcal{G})
$$
of Remark \ref{remark-pullback-internal-hom} is an isomorphism.
\end{lemma}

\begin{proof}
Say $f$ is given by the continuous functor $u : \mathcal{D} \to \mathcal{C}$.
We have to show that the restriction of the map to $\mathcal{C}/U$
for any $U \in \Ob(\mathcal{C})$ is an isomorphism.
We may replace $U$ by the members of a covering of $U$.
Hence by Sites, Lemma \ref{sites-lemma-morphism-of-sites-covering}
we may assume there exists a morphism $U \to u(V)$ for some
$V \in \Ob(\mathcal{C})$. Of course, then we may replace $U$ by $u(V)$.
Then since $u$ is continuous, we may replace $V$ by a covering
and assume there is a presentation
$\mathcal{O}_V^{\oplus m} \to \mathcal{O}_V^{\oplus n} \to
\mathcal{F}|_V \to 0$
over $\mathcal{D}/V$. Since formation of $\SheafHom$
commutes with localization (Lemma \ref{lemma-internal-hom-restriction})
we may replace $f$ by the morphism
$(\mathcal{C}/u(V), \mathcal{O}_{u(V)}) \to
(\mathcal{D}/V, \mathcal{O}_V)$ induced by $f$.
Hence we reduce to the case where $\mathcal{F}$ has a global
presentation
$\mathcal{O}_\mathcal{D}^{\oplus m} \to \mathcal{O}_\mathcal{D}^{\oplus n} \to
\mathcal{F} \to 0$.
Since $f$ is flat and $f^*\mathcal{O}_\mathcal{D} = \mathcal{O}_\mathcal{C}$
we obtain a corresponding presentation
$\mathcal{O}_\mathcal{C}^{\oplus m} \to \mathcal{O}_\mathcal{C}^{\oplus n} \to
f^*\mathcal{F} \to 0$, see
Lemma \ref{lemma-flat-pullback-exact}.
Using that $\SheafHom$ commutes with finite direct sums in the
first variable, using that both
$\SheafHom_{\mathcal{O}_\mathcal{C}}(\mathcal{O}_\mathcal{C}, -)$ and
$\SheafHom_{\mathcal{O}_\mathcal{D}}(\mathcal{O}_\mathcal{D}, -)$
are the identity functor, and using the
functoriality of the construction of
Remark \ref{remark-pullback-internal-hom}
we obtain a commutative diagram
$$
\xymatrix{
0 \ar[r] &
f^*\SheafHom_{\mathcal{O}_\mathcal{D}}(\mathcal{F}, \mathcal{G})
\ar[d] \ar[r] &
f^*\mathcal{G}^{\oplus n} \ar[d] \ar[r] &
f^*\mathcal{G}^{\oplus n} \ar[d] \\
0 \ar[r] &
\SheafHom_{\mathcal{O}_\mathcal{C}}(f^*\mathcal{F}, f^*\mathcal{G})
\ar[r] &
f^*\mathcal{G}^{\oplus n} \ar[r] &
f^*\mathcal{G}^{\oplus n}
}
$$
where the right two vertical arrows are isomorphisms.
By Lemma \ref{lemma-internal-hom-exact} the rows are exact.
We conclude by the 5 lemma.
\end{proof}







\section{Invertible modules}
\label{section-invertible}

\noindent
Here is the definition.

\begin{definition}
\label{definition-invertible-sheaf}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
\begin{enumerate}
\item A finite locally free $\mathcal{O}$-module $\mathcal{F}$ is said
to have {\it rank $r$} if for every object $U$ of $\mathcal{C}$ there
exists a covering $\{U_i \to U\}$ of $U$ such that $\mathcal{F}|_{U_i}$
is isomorphic to $\mathcal{O}_{U_i}^{\oplus r}$ as an
$\mathcal{O}_{U_i}$-module.
\item An $\mathcal{O}$-module $\mathcal{L}$ is {\it invertible}
if the functor
$$
\textit{Mod}(\mathcal{O}) \longrightarrow \textit{Mod}(\mathcal{O}),\quad
\mathcal{F}  \longmapsto \mathcal{F} \otimes_\mathcal{O} \mathcal{L}
$$
is an equivalence.
\item The sheaf {\it $\mathcal{O}^*$} is the subsheaf of
$\mathcal{O}$ defined by the rule
$$
U \longmapsto \mathcal{O}^*(U) = \{f \in \mathcal{O}(U) \mid
\exists g \in \mathcal{O}(U)\text{ such that }fg = 1\}
$$
It is a sheaf of abelian groups with multiplication as the group law.
\end{enumerate}
\end{definition}

\noindent
Lemma \ref{lemma-invertible-is-locally-free-rank-1}
below explains the relationship with locally free modules
of rank $1$.

\begin{lemma}
\label{lemma-invertible}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let $\mathcal{L}$
be an $\mathcal{O}$-module. The following are equivalent:
\begin{enumerate}
\item $\mathcal{L}$ is invertible, and
\item there exists an $\mathcal{O}$-module $\mathcal{N}$
such that
$\mathcal{L} \otimes_\mathcal{O} \mathcal{N} \cong \mathcal{O}$.
\end{enumerate}
In this case we have
\begin{enumerate}
\item[(a)] $\mathcal{L}$ is a flat $\mathcal{O}$-module of finite presentation,
\item[(b)] for every object $U$ of $\mathcal{C}$ there exists a
covering $\{U_i \to U\}$ such that $\mathcal{L}|_{U_i}$
is a direct summand of a finite free module, and
\item[(c)] the module $\mathcal{N}$ in (2) is isomorphic to
$\SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O})$.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1). Then the functor $- \otimes_\mathcal{O} \mathcal{L}$
is essentially surjective, hence there exists an $\mathcal{O}$-module
$\mathcal{N}$ as in (2). If (2) holds, then the functor
$- \otimes_\mathcal{O} \mathcal{N}$ is a quasi-inverse
to the functor $- \otimes_\mathcal{O} \mathcal{L}$ and
we see that (1) holds.

\medskip\noindent
Assume (1) and (2) hold. Since $- \otimes_\mathcal{O} \mathcal{L}$ is an
equivalence, it is exact, and hence $\mathcal{L}$ is flat. Denote
$\psi : \mathcal{L} \otimes_\mathcal{O} \mathcal{N} \to \mathcal{O}$
the given isomorphism. Let $U$ be an object of $\mathcal{C}$.
We will show that the restriction $\mathcal{L}$ to the members
of a covering of $U$ is a direct summand of a free module, which will
certainly imply that $\mathcal{L}$ is of finite presentation.
By construction of $\otimes$ we may assume (after replacing
$U$ by the members of a covering) that there exists
an integer $n \geq 1$ and sections $x_i \in \mathcal{L}(U)$,
$y_i \in \mathcal{N}(U)$ such that $\psi(\sum x_i \otimes y_i) = 1$.
Consider the isomorphisms
$$
\mathcal{L}|_U \to
\mathcal{L}|_U \otimes_{\mathcal{O}_U}
\mathcal{L}|_U \otimes_{\mathcal{O}_U} \mathcal{N}|_U \to \mathcal{L}|_U
$$
where the first arrow sends $x$ to $\sum x_i \otimes x \otimes y_i$
and the second arrow sends $x \otimes x' \otimes y$ to $\psi(x' \otimes y)x$.
We conclude that $x \mapsto \sum \psi(x \otimes y_i)x_i$ is
an automorphism of $\mathcal{L}|_U$. This automorphism factors as
$$
\mathcal{L}|_U \to \mathcal{O}_U^{\oplus n} \to \mathcal{L}|_U
$$
where the first arrow is given by
$x \mapsto (\psi(x \otimes y_1), \ldots, \psi(x \otimes y_n))$
and the second arrow by $(a_1, \ldots, a_n) \mapsto \sum a_i x_i$.
In this way we conclude that $\mathcal{L}|_U$ is a direct summand
of a finite free $\mathcal{O}_U$-module.

\medskip\noindent
Assume (1) and (2) hold. Consider the evaluation map
$$
\mathcal{L} \otimes_\mathcal{O}
\SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O}_X)
\longrightarrow \mathcal{O}_X
$$
To finish the proof of the lemma we will show this is an isomorphism.
By Lemma \ref{lemma-internal-hom-adjoint-tensor} we have
$$
\Hom_\mathcal{O}(\mathcal{O}, \mathcal{O}) =
\Hom_\mathcal{O}
(\mathcal{N} \otimes_\mathcal{O} \mathcal{L}, \mathcal{O})
\longrightarrow
\Hom_\mathcal{O}
(\mathcal{N}, \SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O}))
$$
The image of $1$ gives a morphism
$\mathcal{N} \to \SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O})$.
Tensoring with $\mathcal{L}$ we obtain
$$
\mathcal{O} = \mathcal{L} \otimes_\mathcal{O} \mathcal{N}
\longrightarrow
\mathcal{L} \otimes_\mathcal{O} \SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O})
$$
This map is the inverse to the evaluation map; computation omitted.
\end{proof}

\begin{lemma}
\label{lemma-pullback-invertible}
Let $f : (\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C}) \to
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$ be a
morphism of ringed topoi. The pullback $f^*\mathcal{L}$ of an
invertible $\mathcal{O}_\mathcal{D}$-module is invertible.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-invertible}
there exists an $\mathcal{O}_\mathcal{D}$-module $\mathcal{N}$ such that
$\mathcal{L} \otimes_{\mathcal{O}_\mathcal{D}} \mathcal{N} \cong
\mathcal{O}_\mathcal{D}$. Pulling back we get
$f^*\mathcal{L} \otimes_{\mathcal{O}_\mathcal{C}} f^*\mathcal{N} \cong
\mathcal{O}_\mathcal{C}$
by Lemma \ref{lemma-tensor-product-pullback}.
Thus $f^*\mathcal{L}$ is invertible by Lemma \ref{lemma-invertible}.
\end{proof}

\begin{lemma}
\label{lemma-constructions-invertible}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
\begin{enumerate}
\item If $\mathcal{L}$, $\mathcal{N}$ are invertible
$\mathcal{O}$-modules, then so is
$\mathcal{L} \otimes_\mathcal{O} \mathcal{N}$.
\item If $\mathcal{L}$ is an invertible
$\mathcal{O}$-module, then so is
$\SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O})$ and the evaluation map
$\mathcal{L} \otimes_\mathcal{O}
\SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O}) \to \mathcal{O}$
is an isomorphism.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) is clear from the definition and part (2) follows from
Lemma \ref{lemma-invertible} and its proof.
\end{proof}

\begin{lemma}
\label{lemma-pic-set}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
There exists a set of invertible modules $\{\mathcal{L}_i\}_{i \in I}$
such that each invertible module on $(\mathcal{C}, \mathcal{O})$
is isomorphic to exactly one of the $\mathcal{L}_i$.
\end{lemma}

\begin{proof}
Omitted, but see Sheaves of Modules, Lemma \ref{modules-lemma-pic-set}.
\end{proof}

\noindent
Lemma \ref{lemma-pic-set} says that the collection of
isomorphism classes of invertible sheaves forms a set.
Lemma \ref{lemma-constructions-invertible} says that
tensor product defines the structure of an abelian group
on this set with inverse of $\mathcal{L}$ given by
$\SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O})$.

\medskip\noindent
In fact, given an invertible $\mathcal{O}$-module
$\mathcal{L}$ and $n \in \mathbf{Z}$ we define the
$n$th {\it tensor power} $\mathcal{L}^{\otimes n}$ of $\mathcal{L}$
as the image of $\mathcal{O}$ under applying the equivalence
$\mathcal{F} \mapsto \mathcal{F} \otimes_\mathcal{O} \mathcal{L}$
exactly $n$ times. This makes sense also for negative $n$ as
we've defined an invertible
$\mathcal{O}$-module as one for which tensoring is an equivalence.
More explicitly, we have
$$
\mathcal{L}^{\otimes n} =
\left\{
\begin{matrix}
\mathcal{O} & \text{if} & n = 0 \\
\SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O}) & \text{if} & n = -1\\
\mathcal{L} \otimes_\mathcal{O} \ldots \otimes_\mathcal{O} \mathcal{L}
& \text{if} & n > 0 \\
\mathcal{L}^{\otimes -1} \otimes_\mathcal{O} \ldots
\otimes_\mathcal{O} \mathcal{L}^{\otimes -1}
& \text{if} & n < -1
\end{matrix}
\right.
$$
see Lemma \ref{lemma-constructions-invertible}.
With this definition we have canonical isomorphisms
$\mathcal{L}^{\otimes n} \otimes_\mathcal{O}
\mathcal{L}^{\otimes m} \to
\mathcal{L}^{\otimes n + m}$, and these isomorphisms
satisfy a commutativity and an associativity constraint
(formulation omitted).

\begin{definition}
\label{definition-pic}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
The {\it Picard group} $\Pic(\mathcal{O})$ of
the ringed site is the
abelian group whose elements are isomorphism classes of
invertible $\mathcal{O}$-modules, with addition
corresponding to tensor product.
\end{definition}









\section{Modules of differentials}
\label{section-differentials}

\noindent
In this section we briefly explain how to define the module of relative
differentials for a morphism of ringed topoi.
We suggest the reader take a look at the corresponding section
in the chapter on commutative algebra
(Algebra, Section \ref{algebra-section-differentials}).

\begin{definition}
\label{definition-derivation}
Let $\mathcal{C}$ be a site. Let $\varphi : \mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of sheaves of rings. Let $\mathcal{F}$
be an $\mathcal{O}_2$-module. A {\it $\mathcal{O}_1$-derivation}
or more precisely a {\it $\varphi$-derivation} into $\mathcal{F}$
is a map $D : \mathcal{O}_2 \to \mathcal{F}$ which is additive, annihilates
the image of $\mathcal{O}_1 \to \mathcal{O}_2$, and satisfies the
{\it Leibniz rule}
$$
D(ab) = aD(b) + D(a)b
$$
for all $a, b$ local sections of $\mathcal{O}_2$
(wherever they are both defined). We denote
$\text{Der}_{\mathcal{O}_1}(\mathcal{O}_2, \mathcal{F})$
the set of $\varphi$-derivations into $\mathcal{F}$.
\end{definition}

\noindent
This is the sheaf theoretic analogue of
Algebra, Definition \ref{definition-derivation}.
Given a derivation $D : \mathcal{O}_2 \to \mathcal{F}$
as in the definition the map on global sections
$$
D : \Gamma(\mathcal{O}_2) \longrightarrow \Gamma(\mathcal{F})
$$
clearly is a $\Gamma(\mathcal{O}_1)$-derivation as in
the algebra definition. Note that if $\alpha : \mathcal{F} \to \mathcal{G}$
is a map of $\mathcal{O}_2$-modules, then there is an induced map
$$
\text{Der}_{\mathcal{O}_1}(\mathcal{O}_2, \mathcal{F})
\longrightarrow
\text{Der}_{\mathcal{O}_1}(\mathcal{O}_2, \mathcal{G})
$$
given by the rule $D \mapsto \alpha \circ D$. In other words
we obtain a functor.

\begin{lemma}
\label{lemma-universal-module}
Let $\mathcal{C}$ be a site. Let $\varphi : \mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of sheaves of rings. The functor
$$
\textit{Mod}(\mathcal{O}_2) \longrightarrow \textit{Ab}, \quad
\mathcal{F} \longmapsto \text{Der}_{\mathcal{O}_1}(\mathcal{O}_2, \mathcal{F})
$$
is representable.
\end{lemma}

\begin{proof}
This is proved in exactly the same way as the analogous statement in algebra.
During this proof, for any sheaf of sets $\mathcal{F}$ on $\mathcal{C}$,
let us denote $\mathcal{O}_2[\mathcal{F}]$ the sheafification of the
presheaf $U \mapsto \mathcal{O}_2(U)[\mathcal{F}(U)]$ where this denotes
the free $\mathcal{O}_2(U)$-module on the set $\mathcal{F}(U)$.
For $s \in \mathcal{F}(U)$ we denote $[s]$ the corresponding section
of $\mathcal{O}_2[\mathcal{F}]$ over $U$. If $\mathcal{F}$ is a sheaf of
$\mathcal{O}_2$-modules, then there is a canonical map
$$
c : \mathcal{O}_2[\mathcal{F}] \longrightarrow \mathcal{F}
$$
which on the presheaf level is given by the rule
$\sum f_s[s] \mapsto \sum f_s s$. We will employ the short hand
$[s] \mapsto s$ to
describe this map and similarly for other maps below. Consider
the map of $\mathcal{O}_2$-modules
\begin{equation}
\label{equation-define-module-differentials}
\begin{matrix}
\mathcal{O}_2[\mathcal{O}_2 \times \mathcal{O}_2] \oplus
\mathcal{O}_2[\mathcal{O}_2 \times \mathcal{O}_2] \oplus
\mathcal{O}_2[\mathcal{O}_1] &
\longrightarrow &
\mathcal{O}_2[\mathcal{O}_2] \\
[(a, b)] \oplus [(f, g)] \oplus [h] & \longmapsto & [a + b] - [a] - [b] + \\
& & [fg] - g[f] - f[g] + \\
& & [\varphi(h)]
\end{matrix}
\end{equation}
with short hand notation as above. Set $\Omega_{\mathcal{O}_2/\mathcal{O}_1}$
equal to the cokernel of this map. Then it is clear that there exists
a map of sheaves of sets
$$
\text{d} : \mathcal{O}_2 \longrightarrow \Omega_{\mathcal{O}_2/\mathcal{O}_1}
$$
mapping a local section $f$ to the image of $[f]$ in
$\Omega_{\mathcal{O}_2/\mathcal{O}_1}$. By construction $\text{d}$
is a $\mathcal{O}_1$-derivation. Next, let $\mathcal{F}$
be a sheaf of $\mathcal{O}_2$-modules and let
$D : \mathcal{O}_2 \to \mathcal{F}$ be a $\mathcal{O}_1$-derivation.
Then we can consider the $\mathcal{O}_2$-linear map
$\mathcal{O}_2[\mathcal{O}_2] \to \mathcal{F}$ which sends $[g]$ to $D(g)$.
It follows from the definition of a derivation that this map annihilates
sections in the image of the map (\ref{equation-define-module-differentials})
and hence defines a map
$$
\alpha_D : \Omega_{\mathcal{O}_2/\mathcal{O}_1} \longrightarrow \mathcal{F}
$$
Since it is clear that $D = \alpha_D \circ \text{d}$ the lemma is proved.
\end{proof}

\begin{definition}
\label{definition-module-differentials}
Let $\mathcal{C}$ be a site. Let $\varphi : \mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of sheaves of rings. The {\it module of differentials}
of the ring map $\varphi$ is the object representing the functor
$\mathcal{F} \mapsto \text{Der}_{\mathcal{O}_1}(\mathcal{O}_2, \mathcal{F})$
which exists by Lemma \ref{lemma-universal-module}.
It is denoted $\Omega_{\mathcal{O}_2/\mathcal{O}_1}$, and the {\it universal
$\varphi$-derivation} is denoted
$\text{d} : \mathcal{O}_2 \to \Omega_{\mathcal{O}_2/\mathcal{O}_1}$.
\end{definition}

\noindent
Since this module and the derivation form the universal object representing
a functor, this notion is clearly intrinsic (i.e., does not depend
on the choice of the site underlying the ringed topos, see
Section \ref{section-intrinsic}).
Note that $\Omega_{\mathcal{O}_2/\mathcal{O}_1}$ is the cokernel of
the map (\ref{equation-define-module-differentials}) of
$\mathcal{O}_2$-modules. Moreover the map $\text{d}$ is described
by the rule that $\text{d}f$ is the image of the local section $[f]$.

\begin{lemma}
\label{lemma-differentials-sheafify}
Let $\mathcal{C}$ be a site. Let $\varphi : \mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of presheaves of rings. Then
$\Omega_{\mathcal{O}_2^\#/\mathcal{O}_1^\#}$ is the sheaf associated to the
presheaf $U \mapsto \Omega_{\mathcal{O}_2(U)/\mathcal{O}_1(U)}$.
\end{lemma}

\begin{proof}
Consider the map (\ref{equation-define-module-differentials}). There is
a similar map of presheaves whose value on $U \in \Ob(\mathcal{C})$ is
$$
\mathcal{O}_2(U)[\mathcal{O}_2(U) \times \mathcal{O}_2(U)] \oplus
\mathcal{O}_2(U)[\mathcal{O}_2(U) \times \mathcal{O}_2(U)] \oplus
\mathcal{O}_2(U)[\mathcal{O}_1(U)]
\longrightarrow
\mathcal{O}_2(U)[\mathcal{O}_2(U)]
$$
The cokernel of this map has value $\Omega_{\mathcal{O}_2(U)/\mathcal{O}_1(U)}$
over $U$ by the construction of the module of differentials in 
Algebra, Definition \ref{algebra-definition-differentials}.
On the other hand, the sheaves in (\ref{equation-define-module-differentials})
are the sheafifications of the presheaves above. Thus the result follows
as sheafification is exact.
\end{proof}

\begin{lemma}
\label{lemma-pullback-differentials}
Let $f : \Sh(\mathcal{D}) \to \Sh(\mathcal{C})$ be a morphism of topoi.
Let $\varphi : \mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of sheaves of rings on $\mathcal{C}$.
Then there is a canonical identification
$f^{-1}\Omega_{\mathcal{O}_2/\mathcal{O}_1} =
\Omega_{f^{-1}\mathcal{O}_2/f^{-1}\mathcal{O}_1}$
compatible with universal derivations.
\end{lemma}

\begin{proof}
This holds because the sheaf $\Omega_{\mathcal{O}_2/\mathcal{O}_1}$
is the cokernel of the map (\ref{equation-define-module-differentials})
and a similar statement holds for
$\Omega_{f^{-1}\mathcal{O}_2/f^{-1}\mathcal{O}_1}$,
because the functor $f^{-1}$ is exact, and because
$f^{-1}(\mathcal{O}_2[\mathcal{O}_2]) =
f^{-1}\mathcal{O}_2[f^{-1}\mathcal{O}_2]$,
$f^{-1}(\mathcal{O}_2[\mathcal{O}_2 \times \mathcal{O}_2]) =
f^{-1}\mathcal{O}_2[f^{-1}\mathcal{O}_2 \times f^{-1}\mathcal{O}_2]$, and
$f^{-1}(\mathcal{O}_2[\mathcal{O}_1]) =
f^{-1}\mathcal{O}_2[f^{-1}\mathcal{O}_1]$.
\end{proof}

\begin{lemma}
\label{lemma-localize-differentials}
Let $\mathcal{C}$ be a site. Let $\varphi : \mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of sheaves of rings. For any object $U$ of $\mathcal{C}$
there is a canonical isomorphism
$$
\Omega_{\mathcal{O}_2/\mathcal{O}_1}|_U =
\Omega_{(\mathcal{O}_2|_U)/(\mathcal{O}_1|_U)}
$$
compatible with universal derivations.
\end{lemma}

\begin{proof}
This is a special case of Lemma \ref{lemma-pullback-differentials}.
\end{proof}

\begin{lemma}
\label{lemma-functoriality-differentials}
Let $\mathcal{C}$ be a site. Let
$$
\xymatrix{
\mathcal{O}_2 \ar[r]_\varphi & \mathcal{O}_2' \\
\mathcal{O}_1 \ar[r] \ar[u] & \mathcal{O}'_1 \ar[u]
}
$$
be a commutative diagram of sheaves of rings on $\mathcal{C}$. The map
$\mathcal{O}_2 \to \mathcal{O}'_2$ composed with the map
$\text{d} : \mathcal{O}'_2 \to \Omega_{\mathcal{O}'_2/\mathcal{O}'_1}$
is a $\mathcal{O}_1$-derivation. Hence we obtain a canonical map of
$\mathcal{O}_2$-modules
$\Omega_{\mathcal{O}_2/\mathcal{O}_1} \to
\Omega_{\mathcal{O}'_2/\mathcal{O}'_1}$.
It is uniquely characterized by the property that
$\text{d}(f)$ maps to $\text{d}(\varphi(f))$
for any local section $f$ of $\mathcal{O}_2$.
In this way $\Omega_{-/-}$ becomes a functor on the category
of arrows of sheaves of rings.
\end{lemma}

\begin{proof}
This lemma proves itself.
\end{proof}

\begin{lemma}
\label{lemma-differential-seq}
In Lemma \ref{lemma-functoriality-differentials} suppose that
$\mathcal{O}_2 \to \mathcal{O}'_2$ is surjective with kernel
$\mathcal{I} \subset \mathcal{O}_2$ and assume that
$\mathcal{O}_1 = \mathcal{O}'_1$. Then there is a canonical exact
sequence of $\mathcal{O}'_2$-modules
$$
\mathcal{I}/\mathcal{I}^2
\longrightarrow
\Omega_{\mathcal{O}_2/\mathcal{O}_1} \otimes_{\mathcal{O}_2} \mathcal{O}'_2
\longrightarrow
\Omega_{\mathcal{O}'_2/\mathcal{O}_1}
\longrightarrow
0
$$
The leftmost map is characterized by the rule that a local section
$f$ of $\mathcal{I}$ maps to $\text{d}f \otimes 1$.
\end{lemma}

\begin{proof}
For a local section $f$ of $\mathcal{I}$ denote $\overline{f}$ the image of
$f$ in $\mathcal{I}/\mathcal{I}^2$. To show that the map
$\overline{f} \mapsto \text{d}f \otimes 1$ is well defined we just have to
check that $\text{d} f_1f_2 \otimes 1 = 0$ if $f_1, f_2$ are local sections
of $\mathcal{I}$. And this is clear from the Leibniz rule
$\text{d} f_1f_2 \otimes 1 =
(f_1 \text{d}f_2 + f_2 \text{d} f_1 )\otimes 1 =
\text{d}f_2 \otimes f_1 + \text{d}f_2 \otimes f_1 = 0$.
A similar computation show this map is
$\mathcal{O}'_2 = \mathcal{O}_2/\mathcal{I}$-linear. The map on the right
is the one from Lemma \ref{lemma-functoriality-differentials}.

\medskip\noindent
To see that the sequence is exact, we argue as follows. Let
$\mathcal{O}''_2 \subset \mathcal{O}'_2$ be the presheaf of
$\mathcal{O}_1$-algebras whose value on $U$ is the image of
$\mathcal{O}_2(U) \to \mathcal{O}'_2(U)$. By
Algebra, Lemma \ref{algebra-lemma-differential-seq}
the sequences
$$
\mathcal{I}(U)/\mathcal{I}(U)^2
\longrightarrow
\Omega_{\mathcal{O}_2(U)/\mathcal{O}_1(U)}
\otimes_{\mathcal{O}_2(U)} \mathcal{O}''_2(U)
\longrightarrow
\Omega_{\mathcal{O}''_2(U)/\mathcal{O}_1(U)}
\longrightarrow
0
$$
are exact for all objects $U$ of $\mathcal{C}$. Since sheafification is
exact this gives an exact sequence of sheaves of
$(\mathcal{O}'_2)^\#$-modules.
By Lemma \ref{lemma-differentials-sheafify}
and the fact that $(\mathcal{O}''_2)^\# = \mathcal{O}'_2$
we conclude.
\end{proof}

\noindent
Here is a particular situation where derivations come up
naturally.

\begin{lemma}
\label{lemma-double-structure-gives-derivation}
Let $\mathcal{C}$ be a site. Let $\varphi : \mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of sheaves of rings.
Consider a short exact sequence
$$
0 \to \mathcal{F} \to \mathcal{A} \to \mathcal{O}_2 \to 0
$$
Here $\mathcal{A}$ is a sheaf of $\mathcal{O}_1$-algebras,
$\pi : \mathcal{A} \to \mathcal{O}_2$ is a surjection
of sheaves of $\mathcal{O}_1$-algebras, and
$\mathcal{F} = \Ker(\pi)$ is its kernel. Assume $\mathcal{F}$ an ideal
sheaf with square zero in $\mathcal{A}$. So $\mathcal{F}$
has a natural structure of an $\mathcal{O}_2$-module.
A section $s : \mathcal{O}_2 \to \mathcal{A}$ of $\pi$
is a $\mathcal{O}_1$-algebra map such that $\pi \circ s = \text{id}$.
Given any section $s : \mathcal{O}_2 \to \mathcal{F}$
of $\pi$ and any $\varphi$-derivation $D : \mathcal{O}_1 \to \mathcal{F}$
the map
$$
s + D : \mathcal{O}_1 \to \mathcal{A}
$$
is a section of $\pi$ and every section $s'$ is of the form $s + D$
for a unique $\varphi$-derivation $D$.
\end{lemma}

\begin{proof}
Recall that the $\mathcal{O}_2$-module structure on $\mathcal{F}$
is given by $h \tau = \tilde h \tau$ (multiplication in $\mathcal{A}$)
where $h$ is a local section of $\mathcal{O}_2$, and
$\tilde h$ is a local lift of $h$ to a local
section of $\mathcal{A}$, and $\tau$ is a local section of $\mathcal{F}$.
In particular, given $s$, we may use $\tilde h = s(h)$.
To verify that $s + D$ is a homomorphism of sheaves of rings we
compute
\begin{eqnarray*}
(s + D)(ab) & = & s(ab) + D(ab) \\
& = & s(a)s(b) + aD(b) + D(a)b \\
& = & s(a) s(b) + s(a)D(b) + D(a)s(b) \\
& = & (s(a) + D(a))(s(b) + D(b))
\end{eqnarray*}
by the Leibniz rule. In the same manner one shows
$s + D$ is a $\mathcal{O}_1$-algebra map because $D$ is
an $\mathcal{O}_1$-derivation. Conversely, given $s'$ we set
$D = s' - s$. Details omitted.
\end{proof}

\begin{definition}
\label{definition-sheaf-differentials}
Let $X = (\Sh(\mathcal{C}), \mathcal{O})$ and
$Y = (\Sh(\mathcal{C}'), \mathcal{O}')$ be ringed topoi.
Let $(f, f^\sharp) : X \to Y$ be a morphism of ringed topoi.
In this situation
\begin{enumerate}
\item for a sheaf $\mathcal{F}$ of $\mathcal{O}$-modules a
{\it $Y$-derivation} $D : \mathcal{O} \to \mathcal{F}$ is just a
$f^\sharp$-derivation, and
\item the {\it sheaf of differentials $\Omega_{X/Y}$ of $X$ over $Y$}
is the module of differentials of
$f^\sharp : f^{-1}\mathcal{O}' \to \mathcal{O}$,
see Definition \ref{definition-module-differentials}.
\end{enumerate}
Thus $\Omega_{X/Y}$ comes equipped with a {\it universal $Y$-derivation}
$\text{d}_{X/Y} : \mathcal{O} \longrightarrow \Omega_{X/Y}$. We sometimes
write $\Omega_{X/Y} = \Omega_f$.
\end{definition}

\noindent
Recall that $f^\sharp : f^{-1}\mathcal{O}' \to \mathcal{O}$ so that
this definition makes sense.

\begin{lemma}
\label{lemma-functoriality-differentials-ringed-topoi}
Let
$X = (\Sh(\mathcal{C}_X), \mathcal{O}_X)$,
$Y = (\Sh(\mathcal{C}_Y), \mathcal{O}_Y)$,
$X' = (\Sh(\mathcal{C}_{X'}), \mathcal{O}_{X'})$, and
$Y' = (\Sh(\mathcal{C}_{Y'}), \mathcal{O}_{Y'})$ be ringed topoi.
Let
$$
\xymatrix{
X' \ar[d] \ar[r]_f & X \ar[d] \\
Y' \ar[r] & Y
}
$$
be a commutative diagram of morphisms of ringed topoi. The map
$f^\sharp : \mathcal{O}_X \to f_*\mathcal{O}_{X'}$ composed with the map
$f_*\text{d}_{X'/Y'} : f_*\mathcal{O}_{X'} \to f_*\Omega_{X'/Y'}$ is a
$Y$-derivation. Hence we obtain a canonical map of $\mathcal{O}_X$-modules
$\Omega_{X/Y} \to f_*\Omega_{X'/Y'}$, and by
adjointness of $f_*$ and $f^*$ a
canonical $\mathcal{O}_{X'}$-module homomorphism
$$
c_f : f^*\Omega_{X/Y} \longrightarrow \Omega_{X'/Y'}.
$$
It is uniquely characterized by the property that
$f^*\text{d}_{X/Y}(t)$ maps to $\text{d}_{X'/Y'}(f^* t)$
for any local section $t$ of $\mathcal{O}_X$.
\end{lemma}

\begin{proof}
This is clear except for the last assertion. Let us explain the meaning of
this. Let $U \in \Ob(\mathcal{C}_X)$ and let $t \in \mathcal{O}_X(U)$.
This is what it means for $t$ to be a local section of $\mathcal{O}_X$.
Now, we may think of $t$ as a map of sheaves of sets
$t : h_U^\# \to \mathcal{O}_X$. Then
$f^{-1}t : f^{-1}h_U^\# \to f^{-1}\mathcal{O}_X$. By $f^*t$ we mean
the composition
$$
\xymatrix{
f^{-1}h_U^\# \ar[rr]^{f^{-1}t} \ar@/^4ex/[rrrr]^{f^*t} & &
f^{-1}\mathcal{O}_X \ar[rr]^{f^\sharp} & &
\mathcal{O}_{X'}
}
$$
Note that $\text{d}_{X/Y}(t) \in \Omega_{X/Y}(U)$. Hence we may think of
$\text{d}_{X/Y}(t)$ as a map $\text{d}_{X/Y}(t) : h_U^\# \to \Omega_{X/Y}$.
Then $f^{-1}\text{d}_{X/Y}(t) : f^{-1}h_U^\# \to f^{-1}\Omega_{X/Y}$.
By $f^*\text{d}_{X/Y}(t)$ we mean the composition
$$
\xymatrix{
f^{-1}h_U^\#
\ar[rr]^{f^{-1}\text{d}_{X/Y}(t)}
\ar@/^4ex/[rrrr]^{f^*\text{d}_{X/Y}(t)} & &
f^{-1}\Omega_{X/Y} \ar[rr]^{1 \otimes \text{id}} & &
f^*\Omega_{X/Y}
}
$$
OK, and now the statement of the lemma means that we have
$$
c_f \circ f^*t = f^*\text{d}_{X/Y}(t)
$$
as maps from $f^{-1}h_U^\#$ to $\Omega_{X'/Y'}$. We omit the verification
that this property holds for $c_f$ as defined in the lemma. (Hint: The first
map $c'_f : \Omega_{X/Y} \to f_*\Omega_{X'/Y'}$ satisfies
$c'_f(\text{d}_{X/Y}(t)) = f_*\text{d}_{X'/Y'}(f^\sharp(t))$ as sections of
$f_*\Omega_{X'/Y'}$ over $U$, and you have to
turn this into the equality above by using adjunction.)
The reason that this uniquely characterizes $c_f$ is that the images
of $f^*\text{d}_{X/Y}(t)$ generate the $\mathcal{O}_{X'}$-module
$f^*\Omega_{X/Y}$ simply because the local sections $\text{d}_{X/Y}(t)$
generate the $\mathcal{O}_X$-module $\Omega_{X/Y}$.
\end{proof}





\section{Finite order differential operators}
\label{section-differential-operators}

\noindent
In this section we introduce differential operators of finite order.
We suggest the reader take a look at the corresponding section
in the chapter on commutative algebra
(Algebra, Section \ref{algebra-section-differential-operators}).

\begin{definition}
\label{definition-differential-operators}
Let $\mathcal{C}$ be a site. Let $\varphi : \mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of sheaves of rings. Let $k \geq 0$ be an integer.
Let $\mathcal{F}$, $\mathcal{G}$ be sheaves of $\mathcal{O}_2$-modules.
A {\it differential operator $D : \mathcal{F} \to \mathcal{G}$ of order $k$}
is an is an $\mathcal{O}_1$-linear map such that for all local sections
$g$ of $\mathcal{O}_2$ the map $s \mapsto D(gs) - gD(s)$ is a
differential operator of order $k - 1$. For the base case $k = 0$
we define a differential operator of order $0$ to be an
$\mathcal{O}_2$-linear map.
\end{definition}

\noindent
If $D : \mathcal{F} \to \mathcal{G}$ is a differential operator of order $k$,
then for all local sections $g$ of $\mathcal{O}_2$ the map $gD$ is a
differential operator of order $k$. The sum of two differential operators of
order $k$ is another. Hence the set of all these
$$
\text{Diff}^k(\mathcal{F}, \mathcal{G}) =
\text{Diff}^k_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F}, \mathcal{G})
$$
is a $\Gamma(\mathcal{C}, \mathcal{O}_2)$-module. We have
$$
\text{Diff}^0(\mathcal{F}, \mathcal{G}) \subset
\text{Diff}^1(\mathcal{F}, \mathcal{G}) \subset
\text{Diff}^2(\mathcal{F}, \mathcal{G}) \subset \ldots
$$
The rule which maps $U \in \Ob(\mathcal{C})$ to the module of
differential operators $D : \mathcal{F}|_U \to \mathcal{G}|_U$
of order $k$ is a sheaf of $\mathcal{O}_2$-modules on the site $\mathcal{C}$.
Thus we obtain a sheaf of differential operators (if we ever need this we will
add a definition here).

\begin{lemma}
\label{lemma-composition-differential-operators}
Let $\mathcal{C}$ be a site.
Let $\mathcal{O}_1 \to \mathcal{O}_2$ be a map of sheaves of rings.
Let $\mathcal{E}, \mathcal{F}, \mathcal{G}$ be sheaves of
$\mathcal{O}_2$-modules.
If $D : \mathcal{E} \to \mathcal{F}$ and $D' : \mathcal{F} \to \mathcal{G}$
are differential operators of order $k$ and $k'$, then $D' \circ D$ is a
differential operator of order $k + k'$.
\end{lemma}

\begin{proof}
Let $g$ be a local section of $\mathcal{O}_2$.
Then the map which sends a local section $x$ of $\mathcal{E}$ to
$$
D'(D(gx)) - gD'(D(x)) = D'(D(gx)) - D'(gD(x)) + D'(gD(x)) - gD'(D(x))
$$
is a sum of two compositions of differential operators of lower order.
Hence the lemma follows by induction on $k + k'$.
\end{proof}

\begin{lemma}
\label{lemma-module-principal-parts}
Let $\mathcal{C}$ be a site.
Let $\mathcal{O}_1 \to \mathcal{O}_2$ be a map of sheaves of rings.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}_2$-modules.
Let $k \geq 0$. There exists a sheaf of $\mathcal{O}_2$-modules
$\mathcal{P}^k_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F})$
and a canonical isomorphism
$$
\text{Diff}^k_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F}, \mathcal{G}) =
\Hom_{\mathcal{O}_2}(
\mathcal{P}^k_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F}), \mathcal{G})
$$
functorial in the $\mathcal{O}_2$-module $\mathcal{G}$.
\end{lemma}

\begin{proof}
The existence follows from general category theoretic arguments
(insert future reference here), but we will also give a direct
construction as this construction will be useful in the future proofs.
We will freely use the notation introduced in the proof of
Lemma \ref{lemma-universal-module}.
Given any differential operator $D : \mathcal{F} \to \mathcal{G}$
we obtain an $\mathcal{O}_2$-linear map
$L_D : \mathcal{O}_2[\mathcal{F}] \to \mathcal{G}$
sending $[m]$ to $D(m)$. If $D$ has order $0$
then $L_D$ annihilates the local sections
$$
[m + m'] - [m] - [m'],\quad
g_0[m] - [g_0m]
$$
where $g_0$ is a local section of $\mathcal{O}_2$ and $m, m'$
are local sections of $\mathcal{F}$. If $D$ has order $1$, then $L_D$
annihilates the local sections
$$
[m + m'] - [m] - [m'],\quad
f[m] - [fm], \quad
g_0g_1[m] - g_0[g_1m] - g_1[g_0m] + [g_1g_0m]
$$
where $f$ is a local section of $\mathcal{O}_1$,
$g_0, g_1$ are local sections of $\mathcal{O}_2$, and
$m, m'$ are local sections of $\mathcal{F}$.
If $D$ has order $k$, then $L_D$ annihilates the local sections
$[m + m'] - [m] - [m']$, $f[m] - [fm]$, and the local sections
$$
g_0g_1\ldots g_k[m] - \sum g_0 \ldots \hat g_i \ldots g_k[g_im] + \ldots
+(-1)^{k + 1}[g_0\ldots g_km]
$$
Conversely, if $L : \mathcal{O}_2[\mathcal{F}] \to \mathcal{G}$ is an
$\mathcal{O}_2$-linear map annihilating all the local sections
listed in the previous sentence, then $m \mapsto L([m])$ is a
differential operator of order $k$. Thus we see that
$\mathcal{P}^k_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F})$
is the quotient of $\mathcal{O}_2[\mathcal{F}]$
by the $\mathcal{O}_2$-submodule generated by these local sections.
\end{proof}

\begin{definition}
\label{definition-module-principal-parts}
Let $\mathcal{C}$ be a site.
Let $\mathcal{O}_1 \to \mathcal{O}_2$ be a map of sheaves of rings.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}_2$-modules.
The module $\mathcal{P}^k_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F})$
constructed in Lemma \ref{lemma-module-principal-parts}
is called the {\it module of principal parts of order $k$} of $\mathcal{F}$.
\end{definition}

\noindent
Note that the inclusions
$$
\text{Diff}^0(\mathcal{F}, \mathcal{G}) \subset
\text{Diff}^1(\mathcal{F}, \mathcal{G}) \subset
\text{Diff}^2(\mathcal{F}, \mathcal{G}) \subset \ldots
$$
correspond via Yoneda's lemma (Categories, Lemma \ref{categories-lemma-yoneda})
to surjections
$$
\ldots \to \mathcal{P}^2_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F})
\to \mathcal{P}^1_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F})
\to \mathcal{P}^0_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F}) = \mathcal{F}
$$

\begin{lemma}
\label{lemma-differential-operators-sheafify}
Let $\mathcal{C}$ be a site. Let $\mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of presheaves of rings. Let $\mathcal{F}$ be a presheaf
of $\mathcal{O}_2$-modules. Then
$\mathcal{P}^k_{\mathcal{O}_2^\#/\mathcal{O}_1^\#}(\mathcal{F}^\#)$
is the sheaf associated to the presheaf
$U \mapsto P^k_{\mathcal{O}_2(U)/\mathcal{O}_1(U)}(\mathcal{F}(U))$.
\end{lemma}

\begin{proof}
This can be proved in exactly the same way as is done for the sheaf
of differentials in Lemma \ref{lemma-differentials-sheafify}.
Perhaps a more pleasing approach is to use the universal property
of Lemma \ref{lemma-module-principal-parts} directly to see the equality.
We omit the details.
\end{proof}

\begin{lemma}
\label{lemma-sequence-of-principal-parts}
Let $\mathcal{C}$ be a site. Let $\mathcal{O}_1 \to \mathcal{O}_2$
be a homomorphism of sheaves of rings. Let $\mathcal{F}$ be a sheaf
of $\mathcal{O}_2$-modules. There is a
canonical short exact sequence
$$
0 \to
\Omega_{\mathcal{O}_2/\mathcal{O}_1} \otimes_{\mathcal{O}_2} \mathcal{F} \to
\mathcal{P}^1_{\mathcal{O}_2/\mathcal{O}_1}(\mathcal{F}) \to
\mathcal{F} \to 0
$$
functorial in $\mathcal{F}$ called the {\it sequence of principal parts}.
\end{lemma}

\begin{proof}
Follows from the commutative algebra version
(Algebra, Lemma \ref{algebra-lemma-sequence-of-principal-parts})
and Lemmas \ref{lemma-differentials-sheafify} and
\ref{lemma-differential-operators-sheafify}.
\end{proof}

\begin{remark}
\label{remark-functoriality-principal-parts}
Let $\mathcal{C}$ be a site. Suppose given a commutative diagram of
sheaves of rings
$$
\xymatrix{
\mathcal{B} \ar[r] & \mathcal{B}' \\
\mathcal{A} \ar[u] \ar[r] & \mathcal{A}' \ar[u]
}
$$
a $\mathcal{B}$-module $\mathcal{F}$, a $\mathcal{B}'$-module $\mathcal{F}'$,
and a $\mathcal{B}$-linear map $\mathcal{F} \to \mathcal{F}'$.
Then we get a compatible system of module maps
$$
\xymatrix{
\ldots \ar[r] &
\mathcal{P}^2_{\mathcal{B}'/\mathcal{A}'}(\mathcal{F}') \ar[r] &
\mathcal{P}^1_{\mathcal{B}'/\mathcal{A}'}(\mathcal{F}') \ar[r] &
\mathcal{P}^0_{\mathcal{B}'/\mathcal{A}'}(\mathcal{F}') \\
\ldots \ar[r] &
\mathcal{P}^2_{\mathcal{B}/\mathcal{A}}(\mathcal{F}) \ar[r] \ar[u] &
\mathcal{P}^1_{\mathcal{B}/\mathcal{A}}(\mathcal{F}) \ar[r] \ar[u] &
\mathcal{P}^0_{\mathcal{B}/\mathcal{A}}(\mathcal{F}) \ar[u]
}
$$
These maps are compatible with further composition of maps of this type.
The easiest way to see this is to use the description of the modules
$\mathcal{P}^k_{\mathcal{B}/\mathcal{A}}(\mathcal{M})$ in terms of
(local) generators and relations in the proof of
Lemma \ref{lemma-module-principal-parts} but it can also be seen
directly from the universal
property of these modules. Moreover, these maps are compatible with
the short exact sequences of Lemma \ref{lemma-sequence-of-principal-parts}.
\end{remark}








\section{The naive cotangent complex}
\label{section-netherlander}

\noindent
This section is the analogue of
Algebra, Section \ref{algebra-section-netherlander}
and
Modules, Section \ref{modules-section-netherlander}.
We advise the reader to read those sections first.

\medskip\noindent
Let $\mathcal{C}$ be a site. Let $\mathcal{A} \to \mathcal{B}$ be a
homomorphism of sheaves of rings on $\mathcal{C}$. In this section,
for any sheaf of sets $\mathcal{E}$ on $\mathcal{C}$ we denote
 $\mathcal{A}[\mathcal{E}]$ the sheafification
of the presheaf $U \mapsto \mathcal{A}(U)[\mathcal{E}(U)]$. Here
$\mathcal{A}(U)[\mathcal{E}(U)]$
denotes the polynomial algebra over $\mathcal{A}(U)$
whose variables correspond to the elements of $\mathcal{E}(U)$.
We denote $[e] \in \mathcal{A}(U)[\mathcal{E}(U)]$ the variable
corresponding to $e \in \mathcal{E}(U)$.
There is a canonical surjection of $\mathcal{A}$-algebras
\begin{equation}
\label{equation-canonical-presentation}
\mathcal{A}[\mathcal{B}] \longrightarrow \mathcal{B},\quad [b] \longmapsto b
\end{equation}
whose kernel we denote $\mathcal{I} \subset \mathcal{A}[\mathcal{B}]$.
It is a simple observation that $\mathcal{I}$ is generated by the
local sections $[b][b'] - [bb']$ and $[a] - a$. According to
Lemma \ref{lemma-differential-seq} there is a canonical map
\begin{equation}
\label{equation-naive-cotangent-complex}
\mathcal{I}/\mathcal{I}^2
\longrightarrow
\Omega_{\mathcal{A}[\mathcal{B}]/\mathcal{A}}
\otimes_{\mathcal{A}[\mathcal{B}]} \mathcal{B}
\end{equation}
whose cokernel is canonically isomorphic to $\Omega_{\mathcal{B}/\mathcal{A}}$.

\begin{definition}
\label{definition-naive-cotangent-complex}
Let $\mathcal{C}$ be a site. Let $\mathcal{A} \to \mathcal{B}$ be a
homomorphism of sheaves of rings on $\mathcal{C}$.
The {\it naive cotangent complex} $\NL_{\mathcal{B}/\mathcal{A}}$
is the chain complex (\ref{equation-naive-cotangent-complex})
$$
\NL_{\mathcal{B}/\mathcal{A}} =
\left(\mathcal{I}/\mathcal{I}^2
\longrightarrow
\Omega_{\mathcal{A}[\mathcal{B}]/\mathcal{A}}
\otimes_{\mathcal{A}[\mathcal{B}]} \mathcal{B}\right)
$$
with $\mathcal{I}/\mathcal{I}^2$ placed in degree $-1$ and
$\Omega_{\mathcal{A}[\mathcal{B}]/\mathcal{A}}
\otimes_{\mathcal{A}[\mathcal{B}]} \mathcal{B}$
placed in degree $0$.
\end{definition}

\noindent
This construction satisfies a functoriality similar to that discussed
in Lemma \ref{lemma-functoriality-differentials} for modules of differentials.
Namely, given a commutative diagram
\begin{equation}
\label{equation-commutative-square-sheaves}
\vcenter{
\xymatrix{
\mathcal{B} \ar[r] & \mathcal{B}' \\
\mathcal{A} \ar[u] \ar[r] & \mathcal{A}' \ar[u]
}
}
\end{equation}
of sheaves of rings on $\mathcal{C}$ there is a canonical
$\mathcal{B}$-linear map of complexes
$$
\NL_{\mathcal{B}/\mathcal{A}} \longrightarrow \NL_{\mathcal{B}'/\mathcal{A}'}
$$
Namely, the maps in the commutative diagram give rise to a canonical map
$\mathcal{A}[\mathcal{B}] \to \mathcal{A}'[\mathcal{B}']$
which maps $\mathcal{I}$ into
$\mathcal{I}' = \Ker(\mathcal{A}'[\mathcal{B}'] \to \mathcal{B}')$.
Thus a map $\mathcal{I}/\mathcal{I}^2 \to \mathcal{I}'/(\mathcal{I}')^2$
and a map between modules of differentials, which together give the
desired map between the naive cotangent complexes.

\medskip\noindent
We can choose a different presentation of $\mathcal{B}$ as a quotient of a
polynomial algebra over $\mathcal{A}$ and still obtain the same object
of $D(\mathcal{B})$. To explain this, suppose that $\mathcal{E}$ is
a sheaves of sets on $\mathcal{C}$ and $\alpha : \mathcal{E} \to \mathcal{B}$
a map of sheaves of sets. Then we obtain an $\mathcal{A}$-algebra
homomorphism $\mathcal{A}[\mathcal{E}] \to \mathcal{B}$. Assume this map
is surjective, and let $\mathcal{J} \subset \mathcal{A}[\mathcal{E}]$
be the kernel. Set
$$
\NL(\alpha) = \left(
\mathcal{J}/\mathcal{J}^2
\longrightarrow
\Omega_{\mathcal{A}[\mathcal{E}]/\mathcal{A}}
\otimes_{\mathcal{A}[\mathcal{E}]} \mathcal{B}\right)
$$
Here is the result.

\begin{lemma}
\label{lemma-NL-up-to-qis}
In the situation above there is a canonical isomorphism
$\NL(\alpha) = \NL_{\mathcal{B}/\mathcal{A}}$ in $D(\mathcal{B})$.
\end{lemma}

\begin{proof}
Observe that $\NL_{\mathcal{B}/\mathcal{A}} = \NL(\text{id}_\mathcal{B})$.
Thus it suffices to show that given two maps
$\alpha_i : \mathcal{E}_i \to \mathcal{B}$ as above, there is a
canonical quasi-isomorphism $\NL(\alpha_1) = \NL(\alpha_2)$ in $D(\mathcal{B})$.
To see this set $\mathcal{E} = \mathcal{E}_1 \amalg \mathcal{E}_2$ and
$\alpha = \alpha_1 \amalg \alpha_2 : \mathcal{E} \to \mathcal{B}$.
Set
$\mathcal{J}_i = \Ker(\mathcal{A}[\mathcal{E}_i] \to \mathcal{B})$
and
$\mathcal{J} = \Ker(\mathcal{A}[\mathcal{E}] \to \mathcal{B})$.
We obtain maps $\mathcal{A}[\mathcal{E}_i] \to \mathcal{A}[\mathcal{E}]$
which send $\mathcal{J}_i$ into $\mathcal{J}$.
Thus we obtain canonical maps of complexes
$$
\NL(\alpha_i) \longrightarrow \NL(\alpha)
$$
and it suffices to show these maps are quasi-isomorphism. To see this
we argue as follows. First, observe that
$H^0(\NL(\alpha_i)) = \Omega_{\mathcal{B}/\mathcal{A}}$ and
$H^0(\NL(\alpha)) = \Omega_{\mathcal{B}/\mathcal{A}}$ by
Lemma \ref{lemma-differential-seq}
hence the map is an isomorphism on cohomology sheaves in degree $0$.
Similarly, we claim that $H^{-1}(\NL(\alpha_i))$ and $H^{-1}(\NL(\alpha))$
are the sheaves associated to the presheaf
$U \mapsto H_1(L_{\mathcal{B}(U)/\mathcal{A}(U)})$ where
$H_1(L_{-/-})$ is as in
Algebra, Definition \ref{algebra-definition-naive-cotangent-complex}.
If the claim holds, then the proof is finished.

\medskip\noindent
Proof of the claim. Let $\alpha : \mathcal{E} \to \mathcal{B}$
be as above. Let $\mathcal{B}' \subset \mathcal{B}$ be the subpresheaf
of $\mathcal{A}$-algebras whose value on $U$ is the image of
$\mathcal{A}(U)[\mathcal{E}(U)] \to \mathcal{B}(U)$. Let $\mathcal{I}'$
be the presheaf whose value on $U$ is the kernel of
$\mathcal{A}(U)[\mathcal{E}(U)] \to \mathcal{B}(U)$. Then $\mathcal{I}$
is the sheafification of $\mathcal{I}'$ and $\mathcal{B}$ is
the sheafification of $\mathcal{B}'$. Similarly,
$H^{-1}(\NL(\alpha))$ is the sheafification of the presheaf
$$
U \longmapsto
\Ker(\mathcal{I}'(U)/\mathcal{I}'(U)^2 \to
\Omega_{\mathcal{A}(U)[\mathcal{E}(U)]/\mathcal{A}(U)}
\otimes_{\mathcal{A}(U)[\mathcal{E}(U)]} \mathcal{B}'(U))
$$
by Lemma \ref{lemma-differentials-sheafify}.
By Algebra, Lemma \ref{algebra-lemma-NL-homotopy} we conclude
$H^{-1}(\NL(\alpha))$ is the sheaf associated to the presheaf
$U \mapsto H_1(L_{\mathcal{B}'(U)/\mathcal{A}(U)})$. Thus we have
to show that the maps
$H_1(L_{\mathcal{B}'(U)/\mathcal{A}(U)}) \to
H_1(L_{\mathcal{B}(U)/\mathcal{A}(U)})$ induce an isomorphism
$\mathcal{H}'_1 \to \mathcal{H}_1$ of sheafifications.

\medskip\noindent
Injectivity of $\mathcal{H}'_1 \to \mathcal{H}_1$. Let
$f \in H_1(L_{\mathcal{B}'(U)/\mathcal{A}(U)})$ map to zero
in $\mathcal{H}_1(U)$. To show: $f$ maps to zero in
$\mathcal{H}'_1(U)$. The assumption means there is a covering
$\{U_i \to U\}$ such that $f$ maps to zero in
$H_1(L_{\mathcal{B}(U_i)/\mathcal{A}(U_i)})$ for all $i$.
Replace $U$ by $U_i$ to get to the point where $f$ maps to zero
in $H_1(L_{\mathcal{B}(U)/\mathcal{A}(U)})$.
By Algebra, Lemma \ref{algebra-lemma-colimits-NL}
we can find a finitely generated subalgebra
$\mathcal{B}'(U) \subset B \subset \mathcal{B}(U)$ such
that $f$ maps to zero in $H_1(L_{B/\mathcal{A}(U)})$.
Since $\mathcal{B} = (\mathcal{B}')^\#$ we can find a covering
$\{U_i \to U\}$ such that $B \to \mathcal{B}(U_i)$ factors
through $\mathcal{B}'(U_i)$. Hence $f$ maps to zero in
$H_1(L_{\mathcal{B}'(U_i)/\mathcal{A}(U_i)})$ as desired.

\medskip\noindent
The surjectivity of $\mathcal{H}'_1 \to \mathcal{H}_1$ is proved
in exactly the same way.
\end{proof}

\begin{lemma}
\label{lemma-pullback-NL}
Let $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$ be morphism of topoi.
Let $\mathcal{A} \to \mathcal{B}$ be a homomorphism of sheaves of rings
on $\mathcal{D}$. Then $f^{-1}\NL_{\mathcal{B}/\mathcal{A}} =
\NL_{f^{-1}\mathcal{B}/f^{-1}\mathcal{A}}$.
\end{lemma}

\begin{proof}
Omitted. Hint: Use Lemma \ref{lemma-pullback-differentials}.
\end{proof}

\noindent
The cotangent complex of a morphism of ringed topoi is defined
in terms of the cotangent complex we defined above.

\begin{definition}
\label{definition-cotangent-complex-morphism-ringed-topoi}
Let $X = (\Sh(\mathcal{C}), \mathcal{O})$ and
$Y = (\Sh(\mathcal{C}'), \mathcal{O}')$ be ringed topoi.
Let $(f, f^\sharp) : X \to Y$ be a morphism of ringed topoi.
The {\it naive cotangent complex} $\NL_f = \NL_{X/Y}$
of the given morphism of ringed topoi is
$\NL_{\mathcal{O}/f^{-1}\mathcal{O}'}$.
We sometimes write $\NL_{X/Y} = \NL_{\mathcal{O}/\mathcal{O}'}$.
\end{definition}









\section{Stalks of modules}
\label{section-stalks}

\noindent
We have to be a bit careful when taking stalks at points,
since the colimit defining a stalk (see
Sites, Equation \ref{sites-equation-stalk})
may not be filtered\footnote{Of course in almost any naturally occurring
case the colimit is filtered and some of the discussion in this section
may be simplified.}. On the other hand, by definition of a point of a site
the stalk functor is exact and commutes with arbitrary colimits.
In other words, it behaves exactly as if the colimit were filtered.

\begin{lemma}
\label{lemma-stalk-exact}
Let $\mathcal{C}$ be a site.
Let $p$ be a point of $\mathcal{C}$.
\begin{enumerate}
\item We have $(\mathcal{F}^\#)_p = \mathcal{F}_p$
for any presheaf of sets on $\mathcal{C}$.
\item The stalk functor
$\Sh(\mathcal{C}) \to \textit{Sets}$,
$\mathcal{F} \mapsto \mathcal{F}_p$ is exact (see
Categories, Definition \ref{categories-definition-exact})
and commutes with arbitrary colimits.
\item The stalk functor
$\textit{PSh}(\mathcal{C}) \to \textit{Sets}$,
$\mathcal{F} \mapsto \mathcal{F}_p$ is exact (see
Categories, Definition \ref{categories-definition-exact})
and commutes with arbitrary colimits.
\end{enumerate}
\end{lemma}

\begin{proof}
By
Sites, Lemma \ref{sites-lemma-point-pushforward-sheaf}
we have (1).
By
Sites, Lemmas \ref{sites-lemma-adjoint-point-push-stalk}
we see that
$\textit{PSh}(\mathcal{C}) \to \textit{Sets}$,
$\mathcal{F} \mapsto \mathcal{F}_p$ is a left adjoint,
and by
Sites, Lemma \ref{sites-lemma-point-pushforward-sheaf}
we see the same thing for
$\Sh(\mathcal{C}) \to \textit{Sets}$,
$\mathcal{F} \mapsto \mathcal{F}_p$.
Hence the stalk functor commutes with arbitrary colimits (see
Categories, Lemma \ref{categories-lemma-adjoint-exact}).
It follows from the definition of a point of a site, see
Sites, Definition \ref{sites-definition-point}
that $\Sh(\mathcal{C}) \to \textit{Sets}$,
$\mathcal{F} \mapsto \mathcal{F}_p$
is exact. Since sheafification is exact
(Sites, Lemma \ref{sites-lemma-sheafification-exact})
it follows that $\textit{PSh}(\mathcal{C}) \to \textit{Sets}$,
$\mathcal{F} \mapsto \mathcal{F}_p$
is exact.
\end{proof}

\noindent
In particular, since the stalk functor $\mathcal{F} \mapsto \mathcal{F}_p$
on presheaves commutes with all finite limits and colimits we may apply the
reasoning of the proof of
Sites,
Proposition \ref{sites-proposition-functoriality-algebraic-structures-topoi}.
The result of such an argument is that if $\mathcal{F}$ is a
(pre)sheaf of algebraic structures listed in
Sites,
Proposition \ref{sites-proposition-functoriality-algebraic-structures-topoi}
then the stalk $\mathcal{F}_p$ is naturally an algebraic structure
of the same kind. Let us explain this in detail when $\mathcal{F}$
is an abelian presheaf. In this case the addition map
$+ : \mathcal{F} \times \mathcal{F} \to \mathcal{F}$ induces
a map
$$
+ :
\mathcal{F}_p \times \mathcal{F}_p
=
(\mathcal{F} \times \mathcal{F})_p
\longrightarrow
\mathcal{F}_p
$$
where the equal sign uses that stalk functor on presheaves of sets
commutes with finite limits. This defines a group structure on
the stalk $\mathcal{F}_p$. In this way we obtain
our stalk functor
$$
\textit{PAb}(\mathcal{C}) \longrightarrow \textit{Ab}, \quad
\mathcal{F} \longmapsto \mathcal{F}_p
$$
By construction the underlying set of $\mathcal{F}_p$ is the stalk of the
underlying presheaf of sets. This also defines our stalk functor for
sheaves of abelian groups by precomposing with the inclusion
$\textit{Ab}(\mathcal{C}) \subset \textit{PAb}(\mathcal{C})$.

\begin{lemma}
\label{lemma-stalk-exact-abelian}
Let $\mathcal{C}$ be a site.
Let $p$ be a point of $\mathcal{C}$.
\begin{enumerate}
\item The functor
$\textit{Ab}(\mathcal{C}) \to \textit{Ab}$,
$\mathcal{F} \mapsto \mathcal{F}_p$ is exact.
\item The stalk functor
$\textit{PAb}(\mathcal{C}) \to \textit{Ab}$,
$\mathcal{F}  \mapsto  \mathcal{F}_p$
is exact.
\item For $\mathcal{F} \in \Ob(\textit{PAb}(\mathcal{C}))$
we have $\mathcal{F}_p = \mathcal{F}^\#_p$.
\end{enumerate}
\end{lemma}

\begin{proof}
This is formal from the results of
Lemma \ref{lemma-stalk-exact}
and the construction of the stalk functor above.
\end{proof}

\noindent
Next, we turn to the case of sheaves of modules.
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
(It suffices for the discussion that $\mathcal{O}$ be a presheaf
of rings.)
Let $\mathcal{F}$ be a presheaf of $\mathcal{O}$-modules.
Let $p$ be a point of $\mathcal{C}$. In this case we get a map
$$
\cdot :
\mathcal{O}_p \times \mathcal{O}_p
=
(\mathcal{O} \times \mathcal{O})_p
\longrightarrow
\mathcal{O}_p
$$
which is the stalk of the multiplication map and
$$
\cdot :
\mathcal{O}_p \times \mathcal{F}_p
=
(\mathcal{O} \times \mathcal{F})_p
\longrightarrow
\mathcal{F}_p
$$
which is the stalk of the multiplication map. We omit the verification
that this defines a ring structure on $\mathcal{O}_p$ and an
$\mathcal{O}_p$-module structure on $\mathcal{F}_p$.
In this way we obtain a functor
$$
\textit{PMod}(\mathcal{O}) \longrightarrow \textit{Mod}(\mathcal{O}_p), \quad
\mathcal{F} \longmapsto \mathcal{F}_p
$$
By construction the underlying set of $\mathcal{F}_p$ is the stalk of the
underlying presheaf of sets. This also defines our stalk functor for
sheaves of $\mathcal{O}$-modules by precomposing with the inclusion
$\textit{Mod}(\mathcal{O}) \subset \textit{PMod}(\mathcal{O})$.

\begin{lemma}
\label{lemma-stalk-exact-modules}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $p$ be a point of $\mathcal{C}$.
\begin{enumerate}
\item The functor
$\textit{Mod}(\mathcal{O}) \to \textit{Mod}(\mathcal{O}_p)$,
$\mathcal{F} \mapsto \mathcal{F}_p$ is exact.
\item The stalk functor
$\textit{PMod}(\mathcal{O}) \to \textit{Mod}(\mathcal{O}_p)$,
$\mathcal{F} \mapsto \mathcal{F}_p$
is exact.
\item For $\mathcal{F} \in \Ob(\textit{PMod}(\mathcal{O}))$
we have $\mathcal{F}_p = \mathcal{F}^\#_p$.
\end{enumerate}
\end{lemma}

\begin{proof}
This is formal from the results of
Lemma \ref{lemma-stalk-exact-abelian},
the construction of the stalk functor above, and
Lemma \ref{lemma-abelian}.
\end{proof}

\begin{lemma}
\label{lemma-pullback-stalk}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi or ringed sites.
Let $p$ be a point of $\mathcal{C}$ or $\Sh(\mathcal{C})$
and set $q = f \circ p$. Then
$$
(f^*\mathcal{F})_p =
\mathcal{F}_q \otimes_{\mathcal{O}_{\mathcal{D}, q}}
\mathcal{O}_{\mathcal{C}, p}
$$
for any $\mathcal{O}_\mathcal{D}$-module $\mathcal{F}$.
\end{lemma}

\begin{proof}
We have
$$
f^*\mathcal{F} =
f^{-1}\mathcal{F} \otimes_{f^{-1}\mathcal{O}_\mathcal{D}}
\mathcal{O}_\mathcal{C}
$$
by definition. Since taking stalks at $p$ (i.e., applying
$p^{-1}$) commutes with $\otimes$ by
Lemma \ref{lemma-tensor-product-pullback}
we win by the relation between the stalk of pullbacks at $p$
and stalks at $q$ explained in
Sites, Lemma \ref{sites-lemma-point-morphism-sites} or
Sites, Lemma \ref{sites-lemma-point-morphism-topoi}.
\end{proof}






\section{Skyscraper sheaves}
\label{section-skyscraper}

\noindent
Let $p$ be a point of a site $\mathcal{C}$ or a topos
$\Sh(\mathcal{C})$. In this section we study the exactness
properties of the functor which associates to an abelian group $A$
the skyscraper sheaf $p_*A$. First, recall that
$p_* : \textit{Sets} \to \Sh(\mathcal{C})$ has a lot
of exactness properties, see
Sites, Lemmas \ref{sites-lemma-stalk-skyscraper} and
\ref{sites-lemma-skyscraper-functor-exact}.

\begin{lemma}
\label{lemma-skyscraper-exact}
Let $\mathcal{C}$ be a site. Let $p$ be a point of
$\mathcal{C}$ or of its associated topos.
\begin{enumerate}
\item The functor $p_* : \textit{Ab} \to \textit{Ab}(\mathcal{C})$,
$A \mapsto p_*A$ is exact.
\item There is a functorial direct sum decomposition
$$
p^{-1}p_*A = A \oplus I(A)
$$
for $A \in \Ob(\textit{Ab})$.
\end{enumerate}
\end{lemma}

\begin{proof}
By
Sites, Lemma \ref{sites-lemma-stalk-skyscraper}
there are functorial maps $A \to p^{-1}p_*A \to A$ whose composition
equals $\text{id}_A$. Hence a functorial direct sum decomposition
as in (2) with $I(A)$ the kernel of the adjunction map
$p^{-1}p_*A \to A$. The functor $p_*$ is left exact by
Lemma \ref{lemma-exactness-pushforward-pullback}.
The functor $p_*$ transforms surjections into surjections by
Sites, Lemma \ref{sites-lemma-skyscraper-functor-exact}.
Hence (1) holds.
\end{proof}

\noindent
To do the same thing for sheaves of modules, suppose given a point
$p$ of a ringed topos $(\Sh(\mathcal{C}), \mathcal{O})$.
Recall that $p^{-1}$ is just the stalk functor.
Hence we can think of $p$ as a morphism of ringed topoi
$$
(p, \text{id}_{\mathcal{O}_p}) :
(\Sh(pt), \mathcal{O}_p)
\longrightarrow
(\Sh(\mathcal{C}), \mathcal{O}).
$$
Thus we get a pullback functor
$p^* : \textit{Mod}(\mathcal{O}) \to \textit{Mod}(\mathcal{O}_p)$
which equals the stalk functor, and which we discussed in
Lemma \ref{lemma-stalk-exact-modules}.
In this section we consider the functor
$p_* : \textit{Mod}(\mathcal{O}_p) \to \textit{Mod}(\mathcal{O})$.

\begin{lemma}
\label{lemma-skyscraper-modules-exact}
Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a ringed topos.
Let $p$ be a point of the topos $\Sh(\mathcal{C})$.
\begin{enumerate}
\item The functor
$p_* : \textit{Mod}(\mathcal{O}_p) \to \textit{Mod}(\mathcal{O})$,
$M \mapsto p_*M$ is exact.
\item The canonical surjection $p^{-1}p_*M \to M$ is $\mathcal{O}_p$-linear.
\item The functorial direct sum decomposition
$p^{-1}p_*M = M \oplus I(M)$ of Lemma \ref{lemma-skyscraper-exact}
is {\bf not} $\mathcal{O}_p$-linear in general.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) and surjectivity in (2)
follow immediately from the corresponding result for abelian
sheaves in
Lemma \ref{lemma-skyscraper-exact}.
Since $p^{-1}\mathcal{O} = \mathcal{O}_p$
we have $p^{-1} = p^*$ and hence $p^{-1}p_*M \to M$
is the same as the counit $p^*p_*M \to M$
of the adjunction for modules, whence linear.

\medskip\noindent
Proof of (3). Suppose that $G$ is a group. Consider the topos
$G\textit{-Sets} = \Sh(\mathcal{T}_G)$
and the point $p : \textit{Sets} \to G\textit{-Sets}$.
See Sites, Section \ref{sites-section-example-sheaf-G-sets} and
Example \ref{sites-example-point-G-sets}.
Here $p^{-1}$ is the functor forgetting
about the $G$-action. And $p_*$ is the right adjoint
of the forgetful functor, sending $M$ to $\text{Map}(G, M)$.
The maps in the direct sum decomposition are the maps
$$
M \to \text{Map}(G, M) \to M
$$
where the first sends $m \in M$ to the constant map with value $m$ and
where the second map is evaluation at the identity element $1$ of $G$.
Next, suppose that $R$ is a ring endowed with an action of $G$.
This determines a sheaf of rings $\mathcal{O}$ on $\mathcal{T}_G$.
The category of $\mathcal{O}$-modules is the category of $R$-modules $M$
endowed with an action of $G$ compatible with the action on $R$.
The $R$-module structure on $\text{Map}(G, M)$ is given by
$$
( r f ) (\sigma) = \sigma(r) f(\sigma)
$$
for $r \in R$ and $f \in \text{Map}(G, M)$. This is true because it is the
unique $G$-invariant $R$-module structure compatible with evaluation at $1$.
The reader observes that in general the image of $M \to \text{Map}(G, M)$
is not an $R$-submodule (for example take $M = R$ and assume the
$G$-action is nontrivial), which concludes the proof.
\end{proof}

\begin{example}
\label{example-ring-with-group-action}
Let $G$ be a group. Consider the site
$\mathcal{T}_G$ and its point $p$, see
Sites, Example \ref{sites-example-point-G-sets}.
Let $R$ be a ring with a $G$-action which corresponds to
a sheaf of rings $\mathcal{O}$ on $\mathcal{T}_G$.
Then $\mathcal{O}_p = R$ where we forget the $G$-action.
In this case $p^{-1}p_*M = \text{Map}(G, M)$ and
$I(M) = \{f : G \to M \mid f(1_G) = 0\}$ and
$M \to \text{Map}(G, M)$ assigns to $m \in M$ the constant
function with value $m$.
\end{example}




\section{Localization and points}
\label{section-localize-points}

\begin{lemma}
\label{lemma-stalk-j-shriek}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $p$ be a point of $\mathcal{C}$. Let $U$ be an object of $\mathcal{C}$.
For $\mathcal{G}$ in $\textit{Mod}(\mathcal{O}_U)$ we have
$$
(j_{U!}\mathcal{G})_p =
\bigoplus\nolimits_q \mathcal{G}_q
$$
where the coproduct is over the points $q$ of $\mathcal{C}/U$
lying over $p$, see
Sites, Lemma \ref{sites-lemma-points-above-point}.
\end{lemma}

\begin{proof}
We use the description of $j_{U!}\mathcal{G}$ as the sheaf associated
to the presheaf
$V \mapsto
\bigoplus\nolimits_{\varphi \in \Mor_\mathcal{C}(V, U)}
\mathcal{G}(V/_\varphi U)$
of
Lemma \ref{lemma-extension-by-zero}.
The stalk of $j_{U!}\mathcal{G}$ at $p$ is equal to the
stalk of this presheaf, see
Lemma \ref{lemma-stalk-exact-modules}.
Let $u : \mathcal{C} \to \textit{Sets}$ be the functor corresponding
to $p$ (see Sites, Section \ref{sites-section-points}).
Hence we see that
$$
(j_{U!}\mathcal{G})_p = \colim_{(V, y)}
\bigoplus\nolimits_{\varphi : V \to U} \mathcal{G}(V/_\varphi U)
$$
where the colimit is taken in the category of abelian groups.
To a quadruple $(V, y, \varphi, s)$ occurring in this colimit, we can assign
$x = u(\varphi)(y) \in u(U)$. Hence we obtain
$$
(j_{U!}\mathcal{G})_p =
\bigoplus\nolimits_{x \in u(U)}
\colim_{(\varphi : V \to U, y), \ u(\varphi)(y) = x} \mathcal{G}(V/_\varphi U).
$$
This is equal to the expression of the lemma by the description
of the points $q$ lying over $x$ in
Sites, Lemma \ref{sites-lemma-points-above-point}.
\end{proof}

\begin{remark}
\label{remark-not-pushforward}
Warning: The result of
Lemma \ref{lemma-stalk-j-shriek}
has no analogue for $j_{U, *}$.
\end{remark}












\section{Pullbacks of flat modules}
\label{section-pullback-flat}

\noindent
The pullback of a flat module along a morphism of ringed topoi is flat.
This is a bit tricky to prove.

\begin{lemma}
\label{lemma-pullback-flat}
\begin{reference}
\cite[Expos\'e V, Corollary 1.7.1]{SGA4}
\end{reference}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi or ringed sites.
Then $f^*\mathcal{F}$ is a flat $\mathcal{O}_\mathcal{C}$-module
whenever $\mathcal{F}$ is a flat $\mathcal{O}_\mathcal{D}$-module.
\end{lemma}

\begin{proof}
Choose a diagram as in
Lemma \ref{lemma-morphism-ringed-topoi-comes-from-morphism-ringed-sites}.
Recall that being a flat module is intrinsic
(see Section \ref{section-intrinsic} and
Definition \ref{definition-flat}).
Hence it suffices to prove the lemma for
the morphism $(h, h^\sharp) :
(\Sh(\mathcal{C}'), \mathcal{O}_{\mathcal{C}'})
\to
(\Sh(\mathcal{D}'), \mathcal{O}_{\mathcal{D}'})$.
In other words, we may assume that
our sites $\mathcal{C}$ and $\mathcal{D}$
have all finite limits and that $f$ is a morphism
of sites induced by a continuous functor $u : \mathcal{D} \to \mathcal{C}$
which commutes with finite limits.

\medskip\noindent
Recall that $f^*\mathcal{F} =
\mathcal{O}_\mathcal{C} \otimes_{f^{-1}\mathcal{O}_\mathcal{D}}
f^{-1}\mathcal{F}$ (Definition \ref{definition-pushforward}).
By Lemma \ref{lemma-flat-change-of-rings} it suffices to
prove that $f^{-1}\mathcal{F}$ is a flat
$f^{-1}\mathcal{O}_\mathcal{D}$-module. Combined with
the previous paragraph this reduces us to the situation
of the next paragraph.

\medskip\noindent
Assume $\mathcal{C}$ and $\mathcal{D}$ are sites which
have all finite limits and that $u : \mathcal{D} \to \mathcal{C}$
is a continuous functor which commutes with finite limits.
Let $\mathcal{O}$ be a sheaf of rings on $\mathcal{D}$
and let $\mathcal{F}$ be a flat $\mathcal{O}$-module.
Then $u$ defines a morphism of sites $f : \mathcal{C} \to \mathcal{D}$
(Sites, Proposition \ref{sites-proposition-get-morphism}).
To show: $f^{-1}\mathcal{F}$ is a flat $f^{-1}\mathcal{O}$-module.
Let $U$ be an object of $\mathcal{C}$ and let
$$
f^{-1}\mathcal{O}|_U \xrightarrow{(f_1, \ldots, f_n)}
f^{-1}\mathcal{O}|_U^{\oplus n} \xrightarrow{(s_1, \ldots, s_n)}
f^{-1}\mathcal{F}|_U
$$
be a complex of $f^{-1}\mathcal{O}|_U$-modules.
Our goal is to construct a factorization of
$(s_1, \ldots, s_n)$ on the members of a covering of $U$
as in Lemma \ref{lemma-flat-eq} part (2).
Consider the elements $s_a \in f^{-1}\mathcal{F}(U)$
and $f_a \in f^{-1}\mathcal{O}(U)$.
Since $f^{-1}\mathcal{F}$, resp.\ $f^{-1}\mathcal{O}$
is the sheafification of $u_p\mathcal{F}$ we may,
after replacing $U$ by the members of a covering,
assume that $s_a$ is the image of an element $s'_a \in u_p\mathcal{F}(U)$ and
$f_a$ is the image of an element $f'_a \in u_p\mathcal{O}(U)$.
Then after another replacement of $U$ by the members of a covering
we may assume that $\sum f'_as'_a$ is zero in $u_p\mathcal{F}(U)$.
Recall that the category $(\mathcal{I}_U^u)^{opp}$ is directed
(Sites, Lemma \ref{sites-lemma-directed})
and that $u_p\mathcal{F}(U) = \colim_{(\mathcal{I}_U^u)^{opp}} \mathcal{F}(V)$
and $u_p\mathcal{O}(U) = \colim_{(\mathcal{I}_U^u)^{opp}} \mathcal{O}(V)$.
Hence we may assume there is a pair $(V, \phi) \in \Ob(\mathcal{I}_U^u)$
where $V$ is an object of $\mathcal{D}$
and $\phi$ is a morphism $\phi : U \to u(V)$ of $\mathcal{D}$
and elements $s''_a \in \mathcal{F}(V)$ and $f''_a \in \mathcal{O}(V)$
whose images in $u_p\mathcal{F}(U)$ and $u_p\mathcal{O}(U)$
are equal to $s'_a$ and $f'_a$ and such that
$\sum f''_a s''_a = 0$ in $\mathcal{F}(V)$.
Then we obtain a complex
$$
\mathcal{O}|_V \xrightarrow{(f''_1, \ldots, f''_n)}
\mathcal{O}|_V^{\oplus n} \xrightarrow{(s''_1, \ldots, s''_n)}
\mathcal{F}|_V
$$
and we can apply the other direction of Lemma \ref{lemma-flat-eq}
to see there exists a covering $\{V_i \to V\}$ of $\mathcal{D}$
and for each $i$ a factorization
$$
\mathcal{O}|_{V_i}^{\oplus n}
\xrightarrow{B''_i}
\mathcal{O}|_{V_i}^{\oplus l_i} \xrightarrow{(t''_{i1}, \ldots, t''_{il_i})}
\mathcal{F}|_{V_i}
$$
of $(s''_1, \ldots, s''_n)|_{V_i}$ such that
$B_i \circ (f''_1, \ldots, f''_n)|_{V_i} = 0$.
Set $U_i = U \times_{\phi, u(V)} u(V_i)$, denote
$B_i \in \text{Mat}(l_i \times n, f^{-1}\mathcal{O}(U_i))$
the image of $B''_i$, and denote
$t_{ij} \in f^{-1}\mathcal{F}(U_i)$ the image of
$t''_{ij}$. Then we get a factorization
$$
f^{-1}\mathcal{O}|_{U_i}^{\oplus n}
\xrightarrow{B_i}
f^{-1}\mathcal{O}|_{U_i}^{\oplus l_i}
\xrightarrow{(t_{i1}, \ldots, t_{il_i})}
\mathcal{F}|_{U_i}
$$
of $(s_1, \ldots, s_n)|_{U_i}$ such that
$B_i \circ (f_1, \ldots, f_n)|_{U_i} = 0$.
This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-stalk-flat}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $p$ be a point of $\mathcal{C}$.
If $\mathcal{F}$ is a flat $\mathcal{O}$-module, then
$\mathcal{F}_p$ is a flat $\mathcal{O}_p$-module.
\end{lemma}

\begin{proof}
In Section \ref{section-skyscraper} we have seen
that we can think of $p$ as a morphism of ringed topoi
$$
(p, \text{id}_{\mathcal{O}_p}) :
(\Sh(pt), \mathcal{O}_p)
\longrightarrow
(\Sh(\mathcal{C}), \mathcal{O}).
$$
such that the pullback functor
$p^* : \textit{Mod}(\mathcal{O}) \to \textit{Mod}(\mathcal{O}_p)$
equals the stalk functor. Thus the lemma follows from
Lemma \ref{lemma-pullback-flat}.
\end{proof}

\begin{lemma}
\label{lemma-check-flat-stalks}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}$-modules.
Let $\{p_i\}_{i \in I}$ be a conservative family of points of $\mathcal{C}$.
Then $\mathcal{F}$ is flat if and only if $\mathcal{F}_{p_i}$ is
a flat $\mathcal{O}_{p_i}$-module for all $i \in I$.
\end{lemma}

\begin{proof}
By
Lemma \ref{lemma-stalk-flat}
we see one of the implications.
For the converse, use that
$(\mathcal{F} \otimes_\mathcal{O} \mathcal{G})_p =
\mathcal{F}_p \otimes_{\mathcal{O}_p} \mathcal{G}_p$
by
Lemma \ref{lemma-tensor-product-pullback} (as taking stalks at $p$
is given by $p^{-1}$) and
Lemma \ref{lemma-check-exactness-stalks}.
\end{proof}

\begin{lemma}
\label{lemma-pullback-ses}
Let
$f : (\Sh(\mathcal{C}'), \mathcal{O}') \to (\Sh(\mathcal{C}), \mathcal{O})$
be a morphism of ringed topoi. Let
$0 \to \mathcal{F} \to \mathcal{G} \to \mathcal{H} \to 0$
be a short exact sequence of $\mathcal{O}$-modules with $\mathcal{H}$
a flat $\mathcal{O}$-module. Then the sequence
$0 \to f^*\mathcal{F} \to f^*\mathcal{G} \to f^*\mathcal{H} \to 0$
is exact as well.
\end{lemma}

\begin{proof}
Since $f^{-1}$ is exact we have the short exact sequence
$0 \to f^{-1}\mathcal{F} \to f^{-1}\mathcal{G} \to f^{-1}\mathcal{H} \to 0$
of $f^{-1}\mathcal{O}$-modules. By
Lemma \ref{lemma-pullback-flat}
the $f^{-1}\mathcal{O}$-module $f^{-1}\mathcal{H}$ is flat. By
Lemma \ref{lemma-flat-tor-zero} this implies that tensoring the sequence
over $f^{-1}\mathcal{O}$ with $\mathcal{O}'$ the sequence
remains exact. Since
$f^*\mathcal{F} = f^{-1}\mathcal{F} \otimes_{f^{-1}\mathcal{O}} \mathcal{O}'$
and similarly for $\mathcal{G}$ and $\mathcal{H}$ we conclude.
\end{proof}





\section{Locally ringed topoi}
\label{section-locally-ringed}


\noindent
A reference for this section is
\cite[Expos\'e IV, Exercice 13.9]{SGA4}.

\begin{lemma}
\label{lemma-locally-ringed}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. The following
are equivalent
\begin{enumerate}
\item For every object $U$ of $\mathcal{C}$ and $f \in \mathcal{O}(U)$
there exists a covering $\{U_j \to U\}$ such that for each $j$
either $f|_{U_j}$ is invertible or $(1 - f)|_{U_j}$ is invertible.
\item For $U \in \Ob(\mathcal{C})$, $n \geq 1$, and
$f_1, \ldots, f_n \in \mathcal{O}(U)$ which generate the unit ideal
in $\mathcal{O}(U)$ there exists a covering $\{U_j \to U\}$
such that for each $j$ there exists an $i$ such that $f_i|_{U_j}$
is invertible.
\item The map of sheaves of sets
$$
(\mathcal{O} \times \mathcal{O})
\amalg
(\mathcal{O} \times \mathcal{O})
\longrightarrow
\mathcal{O} \times \mathcal{O}
$$
which maps $(f, a)$ in the first component to $(f, af)$ and
$(f, b)$ in the second component to $(f, b(1 - f))$ is surjective.
\end{enumerate}
\end{lemma}

\begin{proof}
It is clear that (2) implies (1). To show that (1) implies (2) we argue by
induction on $n$. The first case is $n = 2$ (since $n = 1$ is trivial).
In this case we have $a_1f_1 + a_2f_2 = 1$ for some
$a_1, a_2 \in \mathcal{O}(U)$. By assumption we can find a covering
$\{U_j \to U\}$ such that for each $j$
either $a_1f_1|_{U_j}$ is invertible or $a_2f_2|_{U_j}$ is invertible.
Hence either $f_1|_{U_j}$ is invertible or $f_2|_{U_j}$ is invertible
as desired. For $n > 2$ we have
$a_1f_1 + \ldots + a_nf_n = 1$ for some $a_1, \ldots, a_n \in \mathcal{O}(U)$.
By the case $n = 2$ we see that we have some covering $\{U_j \to U\}_{j \in J}$
such that for each $j$ either $f_n|_{U_j}$ is invertible or
$a_1f_1 + \ldots + a_{n - 1}f_{n - 1}|_{U_j}$ is invertible.
Say the first case happens for $j \in J_n$. Set $J' = J \setminus J_n$.
By induction hypothesis, for each $j \in J'$ we can find a covering
$\{U_{jk} \to U_j\}_{k \in K_j}$ such that for each $k \in K_j$ there
exists an $i \in \{1, \ldots, n - 1\}$ such that
$f_i|_{U_{jk}}$ is invertible. By the axioms of a site the family of
morphisms
$\{U_j \to U\}_{j \in J_n} \cup \{U_{jk} \to U\}_{j \in J', k \in K_j}$
is a covering which has the desired property.

\medskip\noindent
Assume (1). To see that the map in (3) is surjective, let
$(f, c)$ be a section of $\mathcal{O} \times \mathcal{O}$ over $U$.
By assumption there exists a covering $\{U_j \to U\}$ such that
for each $j$ either $f$ or $1 - f$ restricts to an invertible section.
In the first case we can take $a = c|_{U_j} (f|_{U_j})^{-1}$, and
in the second case we can take $b = c|_{U_j} (1 - f|_{U_j})^{-1}$.
Hence $(f, c)$ is in the image of the map on each of the members.
Conversely, assume (3) holds. For any $U$ and $f \in \mathcal{O}(U)$
there exists a covering $\{U_j \to U\}$ of $U$ such that the
section $(f, 1)|_{U_j}$ is in the image of the map in (3) on sections
over $U_j$. This means precisely that either $f$ or $1 - f$ restricts
to an invertible section over $U_j$, and we see that (1) holds.
\end{proof}

\begin{lemma}
\label{lemma-locally-ringed-stalk}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Consider the following conditions
\begin{enumerate}
\item For every object $U$ of $\mathcal{C}$ and $f \in \mathcal{O}(U)$
there exists a covering $\{U_j \to U\}$ such that for each $j$
either $f|_{U_j}$ is invertible or $(1 - f)|_{U_j}$ is invertible.
\item For every point $p$ of $\mathcal{C}$ the stalk $\mathcal{O}_p$
is either the zero ring or a local ring.
\end{enumerate}
We always have (1) $\Rightarrow$ (2). If $\mathcal{C}$ has enough points
then (1) and (2) are equivalent.
\end{lemma}

\begin{proof}
Assume (1). Let $p$ be a point of $\mathcal{C}$ given by a functor
$u : \mathcal{C} \to \textit{Sets}$. Let
$f_p \in \mathcal{O}_p$. Since $\mathcal{O}_p$ is computed by
Sites, Equation (\ref{sites-equation-stalk})
we may represent $f_p$ by a triple
$(U, x, f)$ where $x \in U(U)$ and $f \in \mathcal{O}(U)$.
By assumption there exists a covering $\{U_i \to U\}$
such that for each $i$ either $f$ or $1 - f$ is invertible
on $U_i$. Because $u$ defines a point of the site we see that
for some $i$ there exists an $x_i \in u(U_i)$ which maps to
$x \in u(U)$. By the discussion surrounding
Sites, Equation (\ref{sites-equation-stalk})
we see that $(U, x, f)$ and $(U_i, x_i, f|_{U_i})$ define the
same element of $\mathcal{O}_p$. Hence we conclude that
either $f_p$ or $1 - f_p$ is invertible. Thus
$\mathcal{O}_p$ is a ring such that for every element $a$
either $a$ or $1 - a$ is invertible. This means that $\mathcal{O}_p$
is either zero or a local ring, see
Algebra, Lemma \ref{algebra-lemma-characterize-local-ring}.

\medskip\noindent
Assume (2) and assume that $\mathcal{C}$ has enough points.
Consider the map of sheaves of sets
$$
\mathcal{O} \times \mathcal{O} \amalg \mathcal{O} \times \mathcal{O}
\longrightarrow
\mathcal{O} \times \mathcal{O}
$$
of
Lemma \ref{lemma-locally-ringed} part (3). For any local ring $R$
the corresponding map
$(R \times R) \amalg (R \times R) \to R \times R$
is surjective, see for example
Algebra, Lemma \ref{algebra-lemma-characterize-local-ring}.
Since each $\mathcal{O}_p$ is a local ring or zero the map is
surjective on stalks. Hence, by our assumption that $\mathcal{C}$
has enough points it is surjective and we win.
\end{proof}

\noindent
In
Modules, Section \ref{modules-section-pathology}
we pointed out how in a ringed space $(X, \mathcal{O}_X)$
there can be an open subspace over which the structure sheaf is zero.
To prevent this we can require the sections $1$ and $0$ to have different
values in every stalk of the space $X$. In the setting of ringed topoi
and ringed sites the condition is that
\begin{equation}
\label{equation-one-is-never-zero}
\emptyset^\# \longrightarrow
\text{Equalizer}(0, 1 : * \longrightarrow \mathcal{O})
\end{equation}
is an isomorphism of sheaves. Here $*$ is the singleton sheaf,
resp.\ $\emptyset^\#$ is the ``empty sheaf'',
i.e., the final, resp.\ initial object in the category of sheaves, see
Sites, Example \ref{sites-example-singleton-sheaf},
resp.\ Section \ref{sites-section-almost-cocontinuous}.
In other words, the condition is that whenever $U \in \Ob(\mathcal{C})$
is not sheaf theoretically empty, then $1, 0 \in \mathcal{O}(U)$ are not
equal. Let us state the obligatory lemma.

\begin{lemma}
\label{lemma-ringed-stalk-not-zero}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Consider the statements
\begin{enumerate}
\item (\ref{equation-one-is-never-zero}) is an isomorphism, and
\item for every point $p$ of $\mathcal{C}$ the stalk $\mathcal{O}_p$
is not the zero ring.
\end{enumerate}
We always have (1) $\Rightarrow$ (2) and if $\mathcal{C}$ has enough points
then (1) $\Leftrightarrow$ (2).
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\noindent
Lemmas \ref{lemma-locally-ringed},
\ref{lemma-locally-ringed-stalk}, and
\ref{lemma-ringed-stalk-not-zero}
motivate the following definition.

\begin{definition}
\label{definition-locally-ringed}
A ringed site $(\mathcal{C}, \mathcal{O})$ is said to be
{\it locally ringed site} if (\ref{equation-one-is-never-zero})
is an isomorphism, and the equivalent properties of
Lemma \ref{lemma-locally-ringed}
are satisfied.
\end{definition}

\noindent
In \cite[Expos\'e IV, Exercice 13.9]{SGA4} the condition that
(\ref{equation-one-is-never-zero}) be an isomorphism is missing leading to
a slightly different notion of a locally ringed site and locally ringed
topos. As we are motivated by the notion of a locally ringed space we decided
to add this condition (see explanation above).

\begin{lemma}
\label{lemma-locally-ringed-intrinsic}
Being a locally ringed site is an intrinsic property.
More precisely,
\begin{enumerate}
\item if $f : \Sh(\mathcal{C}') \to \Sh(\mathcal{C})$
is a morphism of topoi and $(\mathcal{C}, \mathcal{O})$ is
a locally ringed site, then $(\mathcal{C}', f^{-1}\mathcal{O})$
is a locally ringed site, and
\item if
$(f, f^\sharp) : (\Sh(\mathcal{C}'), \mathcal{O}')
\to (\Sh(\mathcal{C}), \mathcal{O})$
is an equivalence of ringed topoi, then
$(\mathcal{C}, \mathcal{O})$ is locally ringed if and only if
$(\mathcal{C}', \mathcal{O}')$
is locally ringed.
\end{enumerate}
\end{lemma}

\begin{proof}
It is clear that (2) follows from (1). To prove (1) note that
as $f^{-1}$ is exact we have $f^{-1}* = *$,
$f^{-1}\emptyset^\# = \emptyset^\#$, and $f^{-1}$ commutes with
products, equalizers and transforms isomorphisms and surjections
into isomorphisms and surjections. Thus $f^{-1}$ transforms the
isomorphism (\ref{equation-one-is-never-zero}) into
its analogue for $f^{-1}\mathcal{O}$ and transforms the surjection of
Lemma \ref{lemma-locally-ringed} part (3)
into the corresponding surjection for $f^{-1}\mathcal{O}$.
\end{proof}

\noindent
In fact
Lemma \ref{lemma-locally-ringed-intrinsic} part (2)
is the analogue of
Schemes, Lemma \ref{schemes-lemma-isomorphism-locally-ringed}.
It assures us that the following definition makes sense.

\begin{definition}
\label{definition-locally-ringed-topos}
A ringed topos $(\Sh(\mathcal{C}), \mathcal{O})$ is said to be
{\it locally ringed} if the underlying ringed site
$(\mathcal{C}, \mathcal{O})$ is locally ringed.
\end{definition}

\noindent
Here is an example of a consequence of being locally ringed.

\begin{lemma}
\label{lemma-invertible-is-locally-free-rank-1}
Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a ringed topos. Any locally free
$\mathcal{O}$-module of rank $1$ is invertible.
If $(\mathcal{C}, \mathcal{O})$ is locally ringed, then
the converse holds as well (but in general this is not the case).
\end{lemma}

\begin{proof}
Assume $\mathcal{L}$ is locally free of rank $1$ and consider the
evaluation map
$$
\mathcal{L} \otimes_\mathcal{O}
\SheafHom_\mathcal{O}(\mathcal{L}, \mathcal{O})
\longrightarrow \mathcal{O}
$$
Given any object $U$ of $\mathcal{C}$ and restricting to the members
of a covering trivializing $\mathcal{L}$, we see
that this map is an isomorphism (details omitted).
Hence $\mathcal{L}$ is invertible by Lemma \ref{lemma-invertible}.

\medskip\noindent
Assume $(\Sh(\mathcal{C}), \mathcal{O})$ is locally ringed.
Let $U$ be an object of $\mathcal{C}$.
In the proof of Lemma \ref{lemma-invertible}
we have seen that there exists a covering $\{U_i \to U\}$
such that $\mathcal{L}|_{\mathcal{C}/U_i}$ is a direct summand
of a finite free $\mathcal{O}_{U_i}$-module. After replacing
$U$ by $U_i$, let
$p : \mathcal{O}_U^{\oplus r} \to \mathcal{O}_U^{\oplus r}$
be a projector whose image is isomorphic to $\mathcal{L}|_{\mathcal{C}/U}$.
Then $p$ corresponds to a matrix
$$
P = (p_{ij}) \in \text{Mat}(r \times r, \mathcal{O}(U))
$$
which is a projector: $P^2  = P$. Set $A = \mathcal{O}(U)$
so that $P \in \text{Mat}(r \times r, A)$.
By Algebra, Lemma \ref{algebra-lemma-finite-projective}
the image of $P$ is a finite locally free module $M$ over $A$.
Hence there are $f_1, \ldots, f_t \in A$ generating the unit
ideal, such that $M_{f_i}$ is finite free. By
Lemma \ref{lemma-locally-ringed} after replacing $U$ by the members of an open
covering, we may assume that $M$ is free. This means that
$\mathcal{L}|_U$ is free (details omitted). Of course, since
$\mathcal{L}$ is invertible, this is
only possible if the rank of $\mathcal{L}|_U$ is $1$
and the proof is complete.
\end{proof}

\noindent
Next, we want to work out what it means to have a morphism of locally ringed
spaces. In order to do this we have the following lemma.

\begin{lemma}
\label{lemma-locally-ringed-morphism}
Let
$(f, f^\sharp) : (\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to (\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi.
Consider the following conditions
\begin{enumerate}
\item The diagram of sheaves
$$
\xymatrix{
f^{-1}(\mathcal{O}^*_\mathcal{D}) \ar[r]_-{f^\sharp} \ar[d] &
\mathcal{O}^*_\mathcal{C} \ar[d] \\
f^{-1}(\mathcal{O}_\mathcal{D}) \ar[r]^-{f^\sharp} &
\mathcal{O}_\mathcal{C}
}
$$
is cartesian.
\item For any point $p$ of $\mathcal{C}$, setting $q = f \circ p$,
the diagram
$$
\xymatrix{
\mathcal{O}^*_{\mathcal{D}, q} \ar[r] \ar[d] &
\mathcal{O}^*_{\mathcal{C}, p} \ar[d] \\
\mathcal{O}_{\mathcal{D}, q} \ar[r] &
\mathcal{O}_{\mathcal{C}, p}
}
$$
of sets is cartesian.
\end{enumerate}
We always have (1) $\Rightarrow$ (2). If $\mathcal{C}$ has enough points
then (1) and (2) are equivalent. If
$(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})$
and
$(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
are locally ringed topoi then (2) is equivalent to
\begin{enumerate}
\item[(3)] For any point $p$ of $\mathcal{C}$, setting $q = f \circ p$,
the ring map $\mathcal{O}_{\mathcal{D}, q} \to \mathcal{O}_{\mathcal{C}, p}$
is a local ring map.
\end{enumerate}
In fact, properties (2), or (3) for a conservative
family of points implies (1).
\end{lemma}

\begin{proof}
This lemma proves itself, in other words, it follows by unwinding the
definitions.
\end{proof}

\begin{definition}
\label{definition-morphism-locally-ringed-topoi}
Let $(f, f^\sharp) : (\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})
\to (\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
be a morphism of ringed topoi. Assume
$(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C})$
and
$(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})$
are locally ringed topoi. We say that $(f, f^\sharp)$ is a
{\it morphism of locally ringed topoi} if and only if the
diagram of sheaves
$$
\xymatrix{
f^{-1}(\mathcal{O}^*_\mathcal{D}) \ar[r]_-{f^\sharp} \ar[d] &
\mathcal{O}^*_\mathcal{C} \ar[d] \\
f^{-1}(\mathcal{O}_\mathcal{D}) \ar[r]^-{f^\sharp} &
\mathcal{O}_\mathcal{C}
}
$$
(see
Lemma \ref{lemma-locally-ringed-morphism})
is cartesian. If $(f, f^\sharp)$ is a morphism of ringed sites, then
we say that it is a {\it morphism of locally ringed sites} if
the associated morphism of ringed topoi is a morphism of locally ringed
topoi.
\end{definition}

\noindent
It is clear that an isomorphism of ringed topoi between locally ringed
topoi is automatically an isomorphism of locally ringed topoi.

\begin{lemma}
\label{lemma-composition-morphisms-locally-ringed-topoi}
Let
$(f, f^\sharp) :
(\Sh(\mathcal{C}_1), \mathcal{O}_1)
\to (\Sh(\mathcal{C}_2), \mathcal{O}_2)$ and
$(g, g^\sharp) :
(\Sh(\mathcal{C}_2), \mathcal{O}_2) \to
(\Sh(\mathcal{C}_3), \mathcal{O}_3)$
be morphisms of locally ringed topoi. Then the composition
$(g, g^\sharp) \circ (f, f^\sharp)$ (see
Definition \ref{definition-ringed-topos})
is also a morphism of locally ringed topoi.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-locally-ringed-intrinsic-morphism}
Let $f : \Sh(\mathcal{C}') \to \Sh(\mathcal{C})$
be a morphism of topoi. If $\mathcal{O}$ is a sheaf of rings
on $\mathcal{C}$, then
$$
f^{-1}(\mathcal{O}^*) = (f^{-1}\mathcal{O})^*.
$$
In particular, if $\mathcal{O}$ turns $\mathcal{C}$ into a locally
ringed site, then setting $f^\sharp = \text{id}$
the morphism of ringed topoi
$$
(f, f^\sharp) :
(\Sh(\mathcal{C}'), f^{-1}\mathcal{O})
\to
(\Sh(\mathcal{C}, \mathcal{O})
$$
is a morphism of locally ringed topoi.
\end{lemma}

\begin{proof}
Note that the diagram
$$
\xymatrix{
\mathcal{O}^* \ar[rr] \ar[d]_{u \mapsto (u, u^{-1})} & &
{*} \ar[d]^{1} \\
\mathcal{O} \times \mathcal{O} \ar[rr]^-{(a, b) \mapsto ab} & &
\mathcal{O}
}
$$
is cartesian. Since $f^{-1}$ is exact we conclude that
$$
\xymatrix{
f^{-1}(\mathcal{O}^*)
\ar[d]_{u \mapsto (u, u^{-1})} \ar[rr] & &
{*} \ar[d]^{1} \\
f^{-1}\mathcal{O} \times f^{-1}\mathcal{O} \ar[rr]^-{(a, b) \mapsto ab} & &
f^{-1}\mathcal{O}
}
$$
is cartesian which implies the first assertion. For the second,
note that $(\mathcal{C}', f^{-1}\mathcal{O})$ is a locally ringed site
by
Lemma \ref{lemma-locally-ringed-intrinsic}
so that the assertion makes sense. Now the first part implies that
the morphism is a morphism of locally ringed topoi.
\end{proof}

\begin{lemma}
\label{lemma-localize-morphism-locally-ringed-topoi}
Localization of locally ringed sites and topoi.
\begin{enumerate}
\item Let $(\mathcal{C}, \mathcal{O})$ be a locally ringed site.
Let $U$ be an object of $\mathcal{C}$. Then the localization
$(\mathcal{C}/U, \mathcal{O}_U)$ is a locally ringed site, and
the localization morphism
$$
(j_U, j_U^\sharp) :
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\to
(\Sh(\mathcal{C}), \mathcal{O})
$$
is a morphism of locally ringed topoi.
\item Let $(\mathcal{C}, \mathcal{O})$ be a locally ringed site.
Let $f : V \to U$ be a morphism of $\mathcal{C}$.
Then the morphism
$$
(j, j^\sharp) :
(\Sh(\mathcal{C}/V), \mathcal{O}_V)
\to
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
$$
of
Lemma \ref{lemma-relocalize}
is a morphism of locally ringed topoi.
\item Let
$(f, f^\sharp) :
(\mathcal{C}, \mathcal{O})
\longrightarrow
(\mathcal{D}, \mathcal{O}')$
be a morphism of locally ringed sites where $f$ is given by the continuous
functor $u : \mathcal{D} \to \mathcal{C}$. Let $V$ be an object of
$\mathcal{D}$ and let $U = u(V)$. Then the morphism
$$
(f', (f')^\sharp) :
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\to
(\Sh(\mathcal{D}/V), \mathcal{O}'_V)
$$
of
Lemma \ref{lemma-localize-morphism-ringed-sites}
is a morphism of locally ringed sites.
\item Let
$(f, f^\sharp) :
(\mathcal{C}, \mathcal{O})
\longrightarrow
(\mathcal{D}, \mathcal{O}')$
be a morphism of locally ringed sites where $f$ is given by the continuous
functor $u : \mathcal{D} \to \mathcal{C}$. Let $V \in \Ob(\mathcal{D})$,
$U \in \Ob(\mathcal{C})$, and $c : U \to u(V)$. Then the morphism
$$
(f_c, (f_c)^\sharp) :
(\Sh(\mathcal{C}/U), \mathcal{O}_U)
\to
(\Sh(\mathcal{D}/V), \mathcal{O}'_V)
$$
of
Lemma \ref{lemma-relocalize-morphism-ringed-sites}
is a morphism of locally ringed topoi.
\item Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a locally
ringed topos. Let $\mathcal{F}$ be a sheaf on $\mathcal{C}$.
Then the localization
$(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})$
is a locally ringed topos and the localization morphism
$$
(j_\mathcal{F}, j_\mathcal{F}^\sharp) :
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\to
(\Sh(\mathcal{C}), \mathcal{O})
$$
is a morphism of locally ringed topoi.
\item  Let $(\Sh(\mathcal{C}), \mathcal{O})$ be a locally
ringed topos. Let $s : \mathcal{G} \to \mathcal{F}$ be a map of sheaves
on $\mathcal{C}$. Then the morphism
$$
(j, j^\sharp) :
(\Sh(\mathcal{C})/\mathcal{G}, \mathcal{O}_\mathcal{G})
\longrightarrow
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
$$
of
Lemma \ref{lemma-relocalize-ringed-topos}
is a morphism of locally ringed topoi.
\item Let
$f :
(\Sh(\mathcal{C}), \mathcal{O})
\longrightarrow
(\Sh(\mathcal{D}), \mathcal{O}')$
be a morphism of locally ringed topoi. Let $\mathcal{G}$ be a sheaf
on $\mathcal{D}$. Set $\mathcal{F} = f^{-1}\mathcal{G}$.
Then the morphism
$$
(f', (f')^\sharp) :
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\longrightarrow
(\Sh(\mathcal{D})/\mathcal{G}, \mathcal{O}'_\mathcal{G})
$$
of
Lemma \ref{lemma-localize-morphism-ringed-topoi}
is a morphism of locally ringed topoi.
\item  Let
$f :
(\Sh(\mathcal{C}), \mathcal{O})
\longrightarrow
(\Sh(\mathcal{D}), \mathcal{O}')$
be a morphism of locally ringed topoi. Let $\mathcal{G}$ be a sheaf
on $\mathcal{D}$, let $\mathcal{F}$ be a sheaf on $\mathcal{C}$, and
let $s : \mathcal{F} \to f^{-1}\mathcal{G}$ be a morphism of sheaves.
Then the morphism
$$
(f_s, (f_s)^\sharp) :
(\Sh(\mathcal{C})/\mathcal{F}, \mathcal{O}_\mathcal{F})
\longrightarrow
(\Sh(\mathcal{D})/\mathcal{G}, \mathcal{O}'_\mathcal{G})
$$
of
Lemma \ref{lemma-relocalize-morphism-ringed-topoi}
is a morphism of locally ringed topoi.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) is clear since $\mathcal{O}_U$ is just the
restriction of $\mathcal{O}$, so
Lemmas \ref{lemma-locally-ringed-intrinsic} and
\ref{lemma-locally-ringed-intrinsic-morphism}
apply. Part (2) is clear as the morphism $(j, j^\sharp)$
is actually a localization of a locally ringed site so (1) applies.
Part (3) is clear also since $(f')^\sharp$ is just the
restriction of $f^\sharp$ to the topos
$\Sh(\mathcal{C})/\mathcal{F}$, see proof of
Lemma \ref{lemma-localize-morphism-ringed-topoi}
(hence the diagram of
Definition \ref{definition-morphism-locally-ringed-topoi}
for the morphism $f'$ is just the restriction of the corresponding
diagram for $f$, and restriction is an exact functor).
Part (4) follows formally on combining (2) and (3).
Parts (5), (6), (7), and (8) follow from their counterparts
(1), (2), (3), and (4) by enlarging the sites as in
Lemma \ref{lemma-morphism-ringed-topoi-comes-from-morphism-ringed-sites}
and translating everything in terms of sites and morphisms of sites using
the comparisons of
Lemmas \ref{lemma-localize-compare},
\ref{lemma-relocalize-compare},
\ref{lemma-localize-morphism-compare}, and
\ref{lemma-relocalize-morphism-compare}.
(Alternatively one could use the same arguments as in the proofs
of (1), (2), (3), and (4) to prove (5), (6), (7), and (8) directly.)
\end{proof}






\section{Lower shriek for modules}
\label{section-lower-shriek-modules}

\noindent
In this section we extend the construction of $g_!$ discussed
in Section \ref{section-exactness-lower-shriek} to the case of
sheaves of modules.

\begin{lemma}
\label{lemma-lower-shriek-modules}
Let $u : \mathcal{C} \to \mathcal{D}$ be a continuous and cocontinuous
functor between sites. Denote
$g : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$ the associated
morphism of topoi. Let $\mathcal{O}_\mathcal{D}$ be a sheaf of rings
on $\mathcal{D}$. Set
$\mathcal{O}_\mathcal{C} = g^{-1}\mathcal{O}_\mathcal{D}$.
Hence $g$ becomes a morphism of ringed topoi with $g^* = g^{-1}$.
In this case there exists a functor
$$
g_! :
\textit{Mod}(\mathcal{O}_\mathcal{C})
\longrightarrow
\textit{Mod}(\mathcal{O}_\mathcal{D})
$$
which is left adjoint to $g^*$.
\end{lemma}

\begin{proof}
Let $U$ be an object of $\mathcal{C}$. For any
$\mathcal{O}_\mathcal{D}$-module $\mathcal{G}$ we have
\begin{align*}
\Hom_{\mathcal{O}_\mathcal{C}}(j_{U!}\mathcal{O}_U, g^{-1}\mathcal{G})
& =
g^{-1}\mathcal{G}(U) \\
& =
\mathcal{G}(u(U)) \\
& =
\Hom_{\mathcal{O}_\mathcal{D}}(j_{u(U)!}\mathcal{O}_{u(U)}, \mathcal{G})
\end{align*}
because $g^{-1}$ is described by restriction, see
Sites, Lemma \ref{sites-lemma-when-shriek}.
Of course a similar formula holds a direct sum of modules
of the form $j_{U!}\mathcal{O}_U$. By
Homology, Lemma \ref{homology-lemma-partially-defined-adjoint}
and
Lemma \ref{lemma-module-quotient-flat}
we see that $g_!$ exists.
\end{proof}

\begin{remark}
\label{remark-when-shriek-equal}
Warning! Let $u : \mathcal{C} \to \mathcal{D}$, $g$, $\mathcal{O}_\mathcal{D}$,
and $\mathcal{O}_\mathcal{C}$ be as in Lemma \ref{lemma-lower-shriek-modules}.
In general it is {\bf not} the case that the diagram
$$
\xymatrix{
\textit{Mod}(\mathcal{O}_\mathcal{C}) \ar[r]_{g_!} \ar[d]_{forget} &
\textit{Mod}(\mathcal{O}_\mathcal{D}) \ar[d]^{forget} \\
\textit{Ab}(\mathcal{C}) \ar[r]^{g^{Ab}_!} &
\textit{Ab}(\mathcal{D})
}
$$
commutes (here $g^{Ab}_!$ is the one from
Lemma \ref{lemma-g-shriek-adjoint}). There is a transformation
of functors
$$
g_!^{Ab} \circ forget \longrightarrow forget \circ g_!
$$
From the proof of Lemma \ref{lemma-lower-shriek-modules}
we see that this is an isomorphism if and only if
$g^{Ab}_!j_{U!}\mathcal{O}_U \to g_!j_{U!}\mathcal{O}_U$
is an isomorphism for all objects $U$ of $\mathcal{C}$.
Since we have $g_!j_{U!}\mathcal{O}_U = j_{u(U)!}\mathcal{O}_{u(U)}$
this holds if and only if
$$
g^{Ab}_!j_{U!}\mathcal{O}_U \longrightarrow j_{u(U)!}\mathcal{O}_{u(U)}
$$
is an isomorphism for all objects $U$ of $\mathcal{C}$. Note that for such a
$U$ we obtain a commutative diagram
$$
\xymatrix{
\mathcal{C}/U \ar[r]_-{u'} \ar[d]_{j_U} & \mathcal{D}/u(U) \ar[d]^{j_{u(U)}} \\
\mathcal{C} \ar[r]^u & \mathcal{D}
}
$$
of cocontinuous functors of sites, see
Sites, Lemma \ref{sites-lemma-localize-cocontinuous}
and therefore $g^{Ab}_!j_{U!} = j_{u(U)!}(g')^{Ab}_!$ where
$g' : \Sh(\mathcal{C}/U) \to \Sh(\mathcal{D}/u(U))$ is the morphism
of topoi induced by the cocontinuous functor $u'$.
Hence we see that $g_! = g^{Ab}_!$ if the canonical map
\begin{equation}
\label{equation-compare-on-localizations}
(g')^{Ab}_!\mathcal{O}_U \longrightarrow \mathcal{O}_{u(U)}
\end{equation}
is an isomorphism for all objects $U$ of $\mathcal{C}$.
\end{remark}

\noindent
The following two results are of a slightly different nature.

\begin{lemma}
\label{lemma-special-square-cocontinuous}
Assume given a commutative diagram
$$
\xymatrix{
(\Sh(\mathcal{C}'), \mathcal{O}_{\mathcal{C}'})
\ar[r]_{(g', (g')^\sharp)} \ar[d]_{(f', (f')^\sharp)} &
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C}) \ar[d]^{(f, f^\sharp)} \\
(\Sh(\mathcal{D}'), \mathcal{O}_{\mathcal{D}'}) \ar[r]^{(g, g^\sharp)} &
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})
}
$$
of ringed topoi. Assume
\begin{enumerate}
\item $f$, $f'$, $g$, and $g'$ correspond to cocontinuous functors
$u$, $u'$, $v$, and $v'$ as in
Sites, Lemma \ref{sites-lemma-cocontinuous-morphism-topoi},
\item $v \circ u' = u \circ v'$,
\item $v$ and $v'$ are continuous as well as cocontinuous,
\item for any object $V'$ of $\mathcal{D}'$ the functor
${}^{u'}_{V'}\mathcal{I} \to {}^{\ \ \ u}_{v(V')}\mathcal{I}$
given by $v$ is cofinal, and
\item $g^{-1}\mathcal{O}_{\mathcal{D}} = \mathcal{O}_{\mathcal{D}'}$
and $(g')^{-1}\mathcal{O}_{\mathcal{C}} = \mathcal{O}_{\mathcal{C}'}$.
\end{enumerate}
Then we have $f'_* \circ (g')^* = g^* \circ f_*$ and
$g'_! \circ (f')^{-1} = f^{-1} \circ g_!$ on modules.
\end{lemma}

\begin{proof}
We have $(g')^*\mathcal{F} = (g')^{-1}\mathcal{F}$ and
$g^*\mathcal{G} = g^{-1}\mathcal{G}$ because of condition (5).
Thus the first equality follows immediately from the corresponding
equality in Sites, Lemma \ref{sites-lemma-special-square-cocontinuous}.
Since the left adjoint functors $g_!$ and $g'_!$ to $g^*$ and $(g')^*$
exist by Lemma \ref{lemma-lower-shriek-modules}
we see that the second equality follows by
uniqueness of adjoint functors.
\end{proof}

\begin{lemma}
\label{lemma-special-square-continuous}
Consider a commutative diagram
$$
\xymatrix{
(\Sh(\mathcal{C}'), \mathcal{O}_{\mathcal{C}'})
\ar[r]_{(g', (g')^\sharp)} \ar[d]_{(f', (f')^\sharp)} &
(\Sh(\mathcal{C}), \mathcal{O}_\mathcal{C}) \ar[d]^{(f, f^\sharp)} \\
(\Sh(\mathcal{D}'), \mathcal{O}_{\mathcal{D}'}) \ar[r]^{(g, g^\sharp)} &
(\Sh(\mathcal{D}), \mathcal{O}_\mathcal{D})
}
$$
of ringed topoi and suppose we have functors
$$
\xymatrix{
\mathcal{C}' \ar[r]_{v'} &
\mathcal{C} \\
\mathcal{D}' \ar[r]^v \ar[u]^{u'} &
\mathcal{D} \ar[u]_u
}
$$
such that (with notation as in
Sites, Sections \ref{sites-section-morphism-sites} and
\ref{sites-section-cocontinuous-morphism-topoi}) we have
\begin{enumerate}
\item $u$ and $u'$ are continuous and give rise to the morphisms
$f$ and $f'$,
\item $v$ and $v'$ are cocontinuous giving rise to the morphisms $g$ and $g'$,
\item $u \circ v = v' \circ u'$,
\item $v$ and $v'$ are continuous as well as cocontinuous, and
\item $g^{-1}\mathcal{O}_{\mathcal{D}} = \mathcal{O}_{\mathcal{D}'}$
and $(g')^{-1}\mathcal{O}_{\mathcal{C}} = \mathcal{O}_{\mathcal{C}'}$.
\end{enumerate}
Then $f'_* \circ (g')^* = g^* \circ f_*$ and
$g'_! \circ (f')^{-1} = f^{-1} \circ g_!$ on modules.
\end{lemma}

\begin{proof}
We have $(g')^*\mathcal{F} = (g')^{-1}\mathcal{F}$ and
$g^*\mathcal{G} = g^{-1}\mathcal{G}$ because of condition (5).
Thus the first equality follows immediately from the corresponding
equality in Sites, Lemma \ref{sites-lemma-special-square-continuous}.
Since the left adjoint functors $g_!$ and $g'_!$ to $g^*$ and $(g')^*$
exist by Lemma \ref{lemma-lower-shriek-modules}
we see that the second equality follows by
uniqueness of adjoint functors.
\end{proof}







\section{Constant sheaves}
\label{section-constant}

\noindent
Let $E$ be a set and let $\mathcal{C}$ be a site. The constant
sheaf with value $E$ is denoted $\underline{E}$, see
Sites, Example \ref{sites-example-constant-sheaf}.
If $E$ is an abelian group, ring, module, etc,
then $\underline{E}$ is a sheaf of abelian groups, rings, modules, etc.

\begin{lemma}
\label{lemma-constant-exact}
Let $\mathcal{C}$ be a site. If $0 \to A \to B \to C \to 0$
is a short exact sequence of abelian groups, then
$0 \to \underline{A} \to \underline{B} \to \underline{C} \to 0$
is an exact sequence of abelian sheaves and in fact it is even
exact as a sequence of abelian presheaves.
\end{lemma}

\begin{proof}
Since sheafification is exact it is clear that
$0 \to \underline{A} \to \underline{B} \to \underline{C} \to 0$
is an exact sequence of abelian sheaves. Thus
$0 \to \underline{A} \to \underline{B} \to \underline{C}$
is an exact sequence of abelian presheaves. To see that
$\underline{B} \to \underline{C}$ is surjective, pick a
set theoretical section $s : C \to B$. This induces a
section $\underline{s} : \underline{C} \to \underline{B}$
of sheaves of sets left inverse to the surjection
$\underline{B} \to \underline{C}$.
\end{proof}

\begin{lemma}
\label{lemma-tensor-with-finitely-presented}
Let $\mathcal{C}$ be a site. Let $\Lambda$ be a ring and let $M$
and $Q$ be $\Lambda$-modules. If $Q$ is a finitely presented
$\Lambda$-module, then we have
$\underline{M \otimes_\Lambda Q}(U) = \underline{M}(U) \otimes_\Lambda Q$
for all $U \in \Ob(\mathcal{C})$.
\end{lemma}

\begin{proof}
Choose a presentation $\Lambda^{\oplus m} \to \Lambda^{\oplus n} \to Q \to 0$.
This gives an exact sequence
$M^{\oplus m} \to M^{\oplus n} \to M \otimes Q \to 0$.
By Lemma \ref{lemma-constant-exact} we obtain an exact sequence
$$
\underline{M}(U)^{\oplus m} \to
\underline{M}(U)^{\oplus n} \to
\underline{M \otimes Q}(U) \to 0
$$
which proves the lemma. (Note that taking sections over $U$ always
commutes with finite direct sums, but not arbitrary direct sums.)
\end{proof}

\begin{lemma}
\label{lemma-flat-sections}
Let $\mathcal{C}$ be a site. Let $\Lambda$ be a coherent ring.
Let $M$ be a flat $\Lambda$-module. For $U \in \Ob(\mathcal{C})$ the
module $\underline{M}(U)$ is a flat $\Lambda$-module.
\end{lemma}

\begin{proof}
Let $I \subset \Lambda$ be a finitely generated ideal.
By Algebra, Lemma \ref{algebra-lemma-flat} it suffices to show that
$\underline{M}(U) \otimes_\Lambda I \to \underline{M}(U)$
is injective. As $\Lambda$ is coherent $I$ is finitely presented as
a $\Lambda$-module. By Lemma \ref{lemma-tensor-with-finitely-presented}
we see that $\underline{M}(U) \otimes I = \underline{M \otimes I}$.
Since $M$ is flat the map $M \otimes I \to M$ is injective,
whence $\underline{M \otimes I} \to \underline{M}$ is injective.
\end{proof}

\begin{lemma}
\label{lemma-completion-flat}
Let $\mathcal{C}$ be a site. Let $\Lambda$ be a Noetherian ring.
Let $I \subset \Lambda$ be an ideal. The sheaf
$\underline{\Lambda}^\wedge = \lim \underline{\Lambda/I^n}$
is a flat $\underline{\Lambda}$-algebra.
Moreover we have canonical identifications
$$
\underline{\Lambda}/I\underline{\Lambda} =
\underline{\Lambda}/\underline{I} =
\underline{\Lambda}^\wedge/I\underline{\Lambda}^\wedge =
\underline{\Lambda}^\wedge/\underline{I} \cdot \underline{\Lambda}^\wedge =
\underline{\Lambda}^\wedge/\underline{I}^\wedge =
\underline{\Lambda/I}
$$
where $\underline{I}^\wedge = \lim \underline{I/I^n}$.
\end{lemma}

\begin{proof}
To prove $\underline{\Lambda}^\wedge$ is flat, it suffices to show that
$\underline{\Lambda}^\wedge(U)$ is flat as a $\Lambda$-module for each
$U \in \Ob(\mathcal{C})$, see
Lemmas \ref{lemma-flatness-presheaves} and
\ref{lemma-flatness-sheafification}.
By Lemma \ref{lemma-flat-sections} we see that
$$
\underline{\Lambda}^\wedge(U) = \lim \underline{\Lambda/I^n}(U)
$$
is a limit of a system of flat $\Lambda/I^n$-modules.
By Lemma \ref{lemma-constant-exact} we see that the transition maps
are surjective. We conclude by
More on Algebra, Lemma \ref{more-algebra-lemma-limit-flat}.

\medskip\noindent
To see the equalities, note that
$\underline{\Lambda}(U)/I\underline{\Lambda}(U) = \underline{\Lambda/I}(U)$
by Lemma \ref{lemma-tensor-with-finitely-presented}.
It follows that $\underline{\Lambda}/I\underline{\Lambda} =
\underline{\Lambda}/\underline{I} = \underline{\Lambda/I}$. The system
of short exact sequences
$$
0 \to \underline{I/I^n}(U) \to \underline{\Lambda/I^n}(U) \to
\underline{\Lambda/I}(U) \to 0
$$
has surjective transition maps, hence gives a short exact sequence
$$
0 \to \lim \underline{I/I^n}(U) \to \lim \underline{\Lambda/I^n}(U) \to
\lim \underline{\Lambda/I}(U) \to 0
$$
see Homology, Lemma \ref{homology-lemma-Mittag-Leffler}. Thus we see that
$\underline{\Lambda}^\wedge/\underline{I}^\wedge =
\underline{\Lambda/I}$. Since
$$
I \underline{\Lambda}^\wedge \subset
\underline{I} \cdot \underline{\Lambda}^\wedge \subset
\underline{I}^\wedge
$$
it suffices to show that
$I \underline{\Lambda}^\wedge(U) = \underline{I}^\wedge(U)$
for all $U$. Choose generators $I = (f_1, \ldots, f_r)$.
For every $n$ we obtain a short exact sequence
$$
0 \to K_n/(I^n)^{\oplus r} \to (\Lambda/I^n)^{\oplus r}
\xrightarrow{(f_1, \ldots, f_r)}
I/I^{n + 1} \to 0
$$
where $K_n =
\{(x_1, \ldots, x_r) \in \Lambda^{\oplus r} \mid \sum x_i f_i \in I^{n + 1}\}$.
We obtain short exact sequences
$$
0 \to \underline{K_n/(I^n)^{\oplus r}}(U) \to
\underline{(\Lambda/I^n)^{\oplus r}}(U) \to
\underline{I/I^{n + 1}}(U) \to 0
$$
A calculation shows $K_n = K + (I^n)^{\oplus r}$, hence
the transition maps
$K_{n + 1}/(I^{n + 1})^{\oplus r} \to K_n/(I^n)^{\oplus r}$ are surjective.
Hence the system of modules on the left hand side has surjective transition
maps and a fortiori has ML. Thus we see that
$(f_1, \ldots, f_r) :
(\underline{\Lambda}^\wedge)^{\oplus r}(U) \to \underline{I}^\wedge(U)$
is surjective by
Homology, Lemma \ref{homology-lemma-Mittag-Leffler}
which is what we wanted to show.
\end{proof}

\begin{lemma}
\label{lemma-locally-constant-finite-type}
Let $\mathcal{C}$ be a site. Let $\Lambda$ be a ring and let $M$ be a
$\Lambda$-module. Assume $\Sh(\mathcal{C})$ is not the empty topos. Then
\begin{enumerate}
\item $\underline{M}$ is a finite type sheaf of $\underline{\Lambda}$-modules
if and only if $M$ is a finite $\Lambda$-module, and
\item $\underline{M}$ is a finitely presented sheaf of
$\underline{\Lambda}$-modules if and only if $M$ is a 
finitely presented $\Lambda$-module.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). If $M$ is generated by $x_1, \ldots, x_r$ then
$x_1, \ldots, x_r$ define global sections of $\underline{M}$ which
generate it, hence $\underline{M}$ is of finite type. Conversely, assume
$\underline{M}$ is of finite type. Let $U \in \mathcal{C}$ be an object
which is not sheaf theoretically empty
(Sites, Definition \ref{sites-definition-empty}).
Such an object exists as we assumed $\Sh(\mathcal{C})$ is not
the empty topos. Then there exists a covering $\{U_i \to U\}$
and finitely many sections $s_{ij} \in \underline{M}(U_i)$ generating
$\underline{M}|_{U_i}$. After refining the covering we may assume
that $s_{ij}$ come from elements $x_{ij}$ of $M$. Then
$x_{ij}$ define global sections of $\underline{M}$ whose restriction
to $U$ generate $\underline{M}$.

\medskip\noindent
Assume there exist elements $x_1, \ldots, x_r$ of $M$ which define
global sections of $\underline{M}$ generating $\underline{M}$
as a sheaf of $\underline{\Lambda}$-modules. We will show that
$x_1, \ldots, x_r$ generate $M$ as a $\Lambda$-module.
Let $x \in M$. We can find a covering $\{U_i \to U\}_{i \in I}$
and $f_{i, j} \in \underline{\Lambda}(U_i)$ such that
$x|_{U_i} = \sum f_{i, j} x_j|_{U_i}$. After refining the covering
we may assume $f_{i, j} \in \Lambda$. Since $U$ is not
sheaf theoretically empty, there is at least one $i \in I$
such that $U_i$ is not sheaf theoretically empty.
Then the map $M \to \underline{M}(U_i)$ is injective (details omitted).
We conclude that $x = \sum f_{i, j}x_j$ in $M$ as desired.

\medskip\noindent
Proof of (2). Assume $\underline{M}$ is a $\underline{\Lambda}$-module
of finite presentation. By (1) we see that $M$ is of finite type.
Choose generators $x_1, \ldots, x_r$ of $M$ as a $\Lambda$-module.
This determines a short exact sequence
$0 \to K \to \Lambda^{\oplus r} \to M \to 0$ which
turns into a short exact sequence
$$
0 \to \underline{K} \to \underline{\Lambda}^{\oplus r} \to \underline{M} \to 0
$$
by Lemma \ref{lemma-constant-exact}. By
Lemma \ref{lemma-kernel-surjection-finite-onto-finite-presentation}
we see that $\underline{K}$ is of finite type. Hence $K$ is a
finite $\Lambda$-module by (1). Thus $M$ is a $\Lambda$-module
of finite presentation.
\end{proof}




\section{Locally constant sheaves}
\label{section-locally-constant}

\noindent
Here is the general definition.

\begin{definition}
\label{definition-locally-constant}
Let $\mathcal{C}$ be a site. Let $\mathcal{F}$ be a sheaf of sets, groups,
abelian groups, rings, modules over a fixed ring $\Lambda$, etc.
\begin{enumerate}
\item We say $\mathcal{F}$ is a
{\it constant sheaf} of
sets, groups, abelian groups, rings, modules over a fixed ring $\Lambda$, etc
if it is isomorphic as a sheaf of
sets, groups, abelian groups, rings, modules over a fixed ring $\Lambda$, etc
to a constant sheaf $\underline{E}$ as in Section \ref{section-constant}.
\item We say $\mathcal{F}$ is {\it locally constant} if for every object
$U$ of $\mathcal{C}$ there exists a
covering $\{U_i \to U\}$ such that $\mathcal{F}|_{U_i}$ is a constant sheaf.
\item If $\mathcal{F}$ is a sheaf of sets or groups, then we say $\mathcal{F}$
is {\it finite locally constant} if the constant values are finite sets or
finite groups.
\end{enumerate}
\end{definition}

\begin{lemma}
\label{lemma-pullback-locally-constant}
Let $f : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$ be a morphism of topoi.
If $\mathcal{G}$ is a locally constant sheaf of
sets, groups, abelian groups, rings, modules over a fixed ring $\Lambda$, etc
on $\mathcal{D}$, the same is true for $f^{-1}\mathcal{G}$
on $\mathcal{C}$.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-morphism-locally-constant}
Let $\mathcal{C}$ be a site with a final object $X$.
\begin{enumerate}
\item Let $\varphi : \mathcal{F} \to \mathcal{G}$ be a map
of locally constant sheaves of sets on $\mathcal{C}$.
If $\mathcal{F}$ is finite locally constant, there exists a
covering $\{U_i \to X\}$ such that
$\varphi|_{U_i}$ is the map of constant sheaves associated to
a map of sets.
\item Let $\varphi : \mathcal{F} \to \mathcal{G}$ be a map
of locally constant sheaves of abelian groups on $\mathcal{C}$.
If $\mathcal{F}$ is finite locally constant, there exists a
covering $\{U_i \to X\}$ such that $\varphi|_{U_i}$ is the map of
constant abelian sheaves associated to a map of abelian groups.
\item Let $\Lambda$ be a ring.
Let $\varphi : \mathcal{F} \to \mathcal{G}$ be a map
of locally constant sheaves of $\Lambda$-modules on $\mathcal{C}$.
If $\mathcal{F}$ is of finite type, then there exists a covering
$\{U_i \to X\}$ such that $\varphi|_{U_i}$ is the map of constant
sheaves of $\Lambda$-modules associated to a map of $\Lambda$-modules.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof omitted.
\end{proof}

\begin{lemma}
\label{lemma-locally-constant}
Let $\mathcal{C}$ be a site. Let $\Lambda$ be a ring.
Let $M$, $N$ be $\Lambda$-modules.
Let $\mathcal{F}, \mathcal{G}$ be a locally constant sheaves of
$\Lambda$-modules.
\begin{enumerate}
\item If $M$ is of finite presentation, then
$$
\underline{\Hom_\Lambda(M, N)} =
\SheafHom_{\underline{\Lambda}}(\underline{M}, \underline{N})
$$
\item If $M$ and $N$ are both of finite presentation, then
$$
\underline{\text{Isom}_\Lambda(M, N)} =
\mathit{Isom}_{\underline{\Lambda}}(\underline{M}, \underline{N})
$$
\item If $\mathcal{F}$ is of finite presentation, then
$\SheafHom_{\underline{\Lambda}}(\mathcal{F}, \mathcal{G})$
is a locally constant sheaf of $\Lambda$-modules.
\item If $\mathcal{F}$ and $\mathcal{G}$ are both of finite presentation, then
$\mathit{Isom}_{\underline{\Lambda}}(\mathcal{F}, \mathcal{G})$
is a locally constant sheaf of sets.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). Set $E = \Hom_\Lambda(M, N)$. We want to show the canonical map
$$
\underline{E}
\longrightarrow
\SheafHom_{\underline{\Lambda}}(\underline{M}, \underline{N})
$$
is an isomorphism. The module $M$ has a presentation
$\Lambda^{\oplus s} \to \Lambda^{\oplus t} \to M \to 0$.
Then $E$ sits in an exact sequence
$$
0 \to E \to \Hom_\Lambda(\Lambda^{\oplus t}, N) \to
\Hom_\Lambda(\Lambda^{\oplus s}, N)
$$
and we have similarly
$$
0 \to
\SheafHom_{\underline{\Lambda}}(\underline{M}, \underline{N}) \to
\SheafHom_{\underline{\Lambda}}(\underline{\Lambda^{\oplus t}}, \underline{N})
\to
\SheafHom_{\underline{\Lambda}}(\underline{\Lambda^{\oplus s}}, \underline{N})
$$
This reduces the question to the case where $M$ is a finite free module
where the result is clear.

\medskip\noindent
Proof of (3). The question is local on $\mathcal{C}$, hence we may assume
$\mathcal{F} = \underline{M}$ and $\mathcal{G} = \underline{N}$
for some $\Lambda$-modules $M$ and $N$.
By Lemma \ref{lemma-locally-constant-finite-type}
the module $M$ is of finite presentation. Thus the result follows from (1).

\medskip\noindent
Parts (2) and (4) follow from parts (1) and (3) and the
fact that $\mathit{Isom}$ can be viewed as the subsheaf of sections of
$\SheafHom_{\underline{\Lambda}}(\mathcal{F}, \mathcal{G})$
which have an inverse in
$\SheafHom_{\underline{\Lambda}}(\mathcal{G}, \mathcal{F})$.
\end{proof}

\begin{lemma}
\label{lemma-kernel-finite-locally-constant}
Let $\mathcal{C}$ be a site.
\begin{enumerate}
\item The category of finite locally constant sheaves of sets
is closed under finite limits and colimits inside $\Sh(\mathcal{C})$.
\item The category of finite locally constant abelian sheaves is a
weak Serre subcategory of $\textit{Ab}(\mathcal{C})$.
\item Let $\Lambda$ be a Noetherian ring. The category of
finite type, locally constant sheaves of $\Lambda$-modules on
$\mathcal{C}$ is a weak Serre subcategory of
$\textit{Mod}(\mathcal{C}, \Lambda)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). We may work locally on $\mathcal{C}$. Hence by
Lemma \ref{lemma-morphism-locally-constant} we may assume
we are given a finite diagram of
finite sets such that our diagram of sheaves is the associated
diagram of constant sheaves. Then we just take the limit or colimit
in the category of sets and take the associated constant sheaf.
Some details omitted.

\medskip\noindent
To prove (2) and (3) we use the criterion of
Homology, Lemma \ref{homology-lemma-characterize-weak-serre-subcategory}.
Existence of kernels and cokernels is argued in the same way
as above. Of course, the reason for using
a Noetherian ring in (3) is to assure us that the kernel of a map
of finite $\Lambda$-modules is a finite $\Lambda$-module.
To see that the category is closed under extensions
(in the case of sheaves $\Lambda$-modules), assume given
an extension of sheaves of $\Lambda$-modules
$$
0 \to \mathcal{F} \to \mathcal{E} \to \mathcal{G} \to 0
$$
on $\mathcal{C}$ with $\mathcal{F}$, $\mathcal{G}$
finite type and locally constant. Localizing on $\mathcal{C}$
we may assume $\mathcal{F}$ and $\mathcal{G}$ are constant, i.e., we
get
$$
0 \to \underline{M} \to \mathcal{E} \to \underline{N} \to 0
$$
for some $\Lambda$-modules $M, N$. Choose generators $y_1, \ldots, y_m$
of $N$, so that we get a short exact sequence
$0 \to K \to \Lambda^{\oplus m} \to N \to 0$ of $\Lambda$-modules.
Localizing further we may assume $y_j$ lifts to a section
$s_j$ of $\mathcal{E}$. Thus we see that $\mathcal{E}$ is a
pushout as in the following diagram
$$
\xymatrix{
0 \ar[r] &
\underline{K} \ar[d] \ar[r] &
\underline{\Lambda^{\oplus m}} \ar[d] \ar[r] &
\underline{N} \ar[d] \ar[r] & 0 \\
0 \ar[r] &
\underline{M} \ar[r] &
\mathcal{E} \ar[r] &
\underline{N} \ar[r] & 0
}
$$
By Lemma \ref{lemma-morphism-locally-constant} again (and the fact that
$K$ is a finite $\Lambda$-module as $\Lambda$ is Noetherian) we see that
the map $\underline{K} \to \underline{M}$ is locally constant, hence
we conclude.
\end{proof}

\begin{lemma}
\label{lemma-tensor-product-locally-constant}
Let $\mathcal{C}$ be a site. Let $\Lambda$ be a ring.
The tensor product of two locally constant sheaves of $\Lambda$-modules
on $\mathcal{C}$ is a locally constant sheaf of $\Lambda$-modules.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}











\section{Localizing sheaves of rings}
\label{section-localizing-sheaves-rings}

\noindent
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\mathcal{S} \subset \mathcal{O}$ be a sub-presheaf of sets
such that for all $U \in \Ob(\mathcal{C})$ the set
$\mathcal{S}(U) \subset \mathcal{O}(U)$ is a multiplicative subset, see
Algebra, Definition \ref{algebra-definition-multiplicative-subset}.
In this case we can consider the presheaf of rings
$$
\mathcal{S}^{-1}\mathcal{O} :
U \longmapsto \mathcal{S}(U)^{-1}\mathcal{O}(U).
$$
The restriction mapping sends the section
$f/s$, $f \in \mathcal{O}(U)$, $s \in \mathcal{S}(U)$
to $(f|_V)/(s|_V)$ for $V \to U$ in $\mathcal{C}$.

\begin{lemma}
\label{lemma-simple-invert}
In the situation above the map to the sheafification
$$
\mathcal{O} \longrightarrow (\mathcal{S}^{-1}\mathcal{O})^\#
$$
is a homomorphism of sheaves of rings with the following
universal property: for any homomorphism of sheaves of rings
$\mathcal{O} \to \mathcal{A}$ such that each local section
of $\mathcal{S}$ maps to an invertible section of $\mathcal{A}$
there exists a unique factorization
$(\mathcal{S}^{-1}\mathcal{O})^\# \to \mathcal{A}$.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\noindent
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $\mathcal{S} \subset \mathcal{O}$
be a sub-presheaf of sets such that for all $U \in \mathcal{C}$ the set
$\mathcal{S}(U) \subset \mathcal{O}(U)$ is a multiplicative subset.
Let $\mathcal{F}$ be a sheaf of $\mathcal{O}$-modules.
In this case we can consider the presheaf of
$\mathcal{S}^{-1}\mathcal{O}$-modules
$$
\mathcal{S}^{-1}\mathcal{F} :
U \longmapsto \mathcal{S}(U)^{-1}\mathcal{F}(U).
$$
The restriction mapping sends the section $t/s$, $t \in \mathcal{F}(U)$,
$s \in \mathcal{S}(U)$ to $(t|_V)/(s|_V)$ if $V \to U$ is a morphism
of $\mathcal{C}$. Then $\mathcal{S}^{-1}\mathcal{F}$ is a presheaf
of $\mathcal{S}^{-1}\mathcal{O}$-modules.

\begin{lemma}
\label{lemma-simple-invert-module}
In the situation above the map to the sheafification
$$
\mathcal{F} \longrightarrow (\mathcal{S}^{-1}\mathcal{F})^\#
$$
has the following universal property: for any homomorphism
of $\mathcal{O}$-modules $\mathcal{F} \to \mathcal{G}$ such
that each local section of $\mathcal{S}$ acts invertibly on $\mathcal{G}$
there exists a unique factorization
$(\mathcal{S}^{-1}\mathcal{F})^\# \to \mathcal{G}$.
Moreover we have
$$
(\mathcal{S}^{-1}\mathcal{F})^\#
=
(\mathcal{S}^{-1}\mathcal{O})^\# \otimes_\mathcal{O} \mathcal{F}
$$
as sheaves of $(\mathcal{S}^{-1}\mathcal{O})^\#$-modules.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}









\section{Sheaves of pointed sets}
\label{section-pointed}

\noindent
In this section we collect some facts about sheaves of pointed sets
which we've previously mentioned only for abelian sheaves.

\medskip\noindent
A pointed set is a pair $(S, 0)$ where $S$ is a set and $0 \in S$
is an element of $S$. A morphism $(S, 0) \to (S', 0')$ of pointed sets
is simply a map of sets $S \to S'$ sending $0$ to $0'$. We'll abuse
notation and say ``let $S$ be a pointed set'' to mean $S$ is endowed
with a marked element $0 \in S$. A sheaf of pointed sets is
the same thing as a sheaf of sets $\mathcal{F}$ endowed with a
``marking'' $0 : * \to \mathcal{F}$ where $*$ is the final sheaf
(Sites, Example \ref{sites-example-singleton-sheaf}).

\medskip\noindent
Given a morphism of sites or of topoi, there are pushforward
and pullback functors on the categories of sheaves of pointed sets, see
Sites, Section \ref{sites-section-sheaves-algebraic-structures}.
These are constructed by taking the pushforward, resp.\ pullback
of the underlying sheaf of sets and suitably marking it (using
that the pullback of the final sheaf is the final sheaf).

\medskip\noindent
Let $u : \mathcal{C} \to \mathcal{D}$ be a continuous and cocontinuous
functor between sites. Let $g : \Sh(\mathcal{C}) \to \Sh(\mathcal{D})$
be the morphism of topoi associated with $u$, see
Sites, Lemma \ref{sites-lemma-cocontinuous-morphism-topoi}.
Then $g^{-1}$ on sheaves of pointed sets has an left adjoint $g_!$
as well. The construction of this functor is entirely analogous to
the construction of $g_!$ on abelian sheaves in
Section \ref{section-exactness-lower-shriek}.

\medskip\noindent
Similarly, if $j : \mathcal{C}/U \to \mathcal{C}$ is as in
Section \ref{section-localize} then there is a left adjoint $j_!$
to the functor $j^{-1}$ on sheaves of pointed sets 

\medskip\noindent
If we ever need these facts and constructions we will precisely
state and prove here the corresponding lemmas.






\input{chapters}

\bibliography{my}
\bibliographystyle{amsalpha}

\end{document}
